我正在尝试为我的django项目建立一个PostgreSQL数据库,我相信我现在已经完成了,这要归功于我为django项目设置postgreSQL数据库时遇到的问题.我现在正试图在终端中运行命令'python manage.py runserver'来获取我的本地主机但是当我运行命令时,我看到这个响应...
Error: No module named psycopg2.extensions
Run Code Online (Sandbox Code Playgroud)
我不确定这意味着什么 - 我试图下载psycopg2但似乎找不到使用自制软件下载psycopg2的方法.我已经尝试过easy_install,pip install和sudo但是所有的返回错误都是这样的......
Downloading http://www.psycopg.org/psycopg/tarballs/PSYCOPG-2-4/psycopg2-2.4.5.tar.gz
Processing psycopg2-2.4.5.tar.gz
Writing /tmp/easy_install-l7Qi62/psycopg2-2.4.5/setup.cfg
Running psycopg2-2.4.5/setup.py -q bdist_egg --dist-dir /tmp/easy_install-l7Qi62/psycopg2-2.4.5/egg-dist-tmp-PBP5Ds
no previously-included directories found matching 'doc/src/_build'
unable to execute gcc-4.0: No such file or directory
error: Setup script exited with error: command 'gcc-4.0' failed with exit status 1
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题?
在 PyCharm 中运行测试时遇到问题。
manage.py test 工作正常。
但是,如果我在 PyCharm Django 测试中运行测试,则会出现以下错误:
AttributeError: 'module' object has no attribute 'ROOT_URLCONF'
DJANGO_SETTINGS_MODULE=project.settings.test
设置: project/settings/test.py
管理脚本: project/manage.py
from django.test import SimpleTestCase
from rest_framework import status
class AccountTestCase(SimpleTestCase):
def test_current_account(self):
url = '/api/accounts/current/'
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_301_MOVED_PERMANENTLY)
Run Code Online (Sandbox Code Playgroud)
Error
packages/django/core/handlers/base.py", line 113, in get_response
urlconf = settings.ROOT_URLCONF
File "/lib/python2.7/site-packages/django/conf/__init__.py", line 56, in __getattr__
return getattr(self._wrapped, name)
File "/lib/python2.7/site-packages/django/conf/__init__.py", line 173, in __getattr__
return getattr(self.default_settings, name)
AttributeError: 'module' object …Run Code Online (Sandbox Code Playgroud)