小编Viv*_*vek的帖子

提高配置不正确的 psycopg2(postgresql)

我是 Django 的新手。我曾尝试在我的项目中配置 postgresql。我遵循的步骤:

1) sudo apt-get install psycopg2

2)改变settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'dbname',
        'USER': 'postgres',
        'PASSWORD': 'postgres',
        'HOST': '',
        'PORT': '',
    }
}
Run Code Online (Sandbox Code Playgroud)

3) 运行 python manage.py makemigrations

但我收到错误

Traceback (most recent call last):
  File "/home/vivekpradhan/joker/basket/local/lib/python3.4/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 20, in <module>
    import psycopg2 as Database
ImportError: No module named 'psycopg2'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/vivekpradhan/joker/basket/local/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, …
Run Code Online (Sandbox Code Playgroud)

python django postgresql python-2.7

4
推荐指数
2
解决办法
4306
查看次数

升级到Django 1.8后,在/ admin/login /中是否存在

从django 1.7升级到1.8后,我无法访问我的管理门户.我收到以下错误:

DoesNotExist at /admin/login/
Site matching query does not exist.
Run Code Online (Sandbox Code Playgroud)

正如其他问题中提到的,我已经改变了我的TEMPLATES设置,但它没有帮助.

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(BASE_DIR, 'MyANSRSource/templates/MyANSRSource/'),
            os.path.join(BASE_DIR, 'employee/template/'),
            os.path.join(BASE_DIR, 'employee/emp_photo/'),
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                # Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
                #global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
                #    'django.template.context_processors.request',

                #),
                # list if you haven't customized them:
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.template.context_processors.debug',
                'django.template.context_processors.i18n',
                'django.template.context_processors.media',
                'django.template.context_processors.static',
                'django.template.context_processors.tz',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]
Run Code Online (Sandbox Code Playgroud)

python django

0
推荐指数
1
解决办法
1396
查看次数

标签 统计

django ×2

python ×2

postgresql ×1

python-2.7 ×1