error to set postgresql9.3 in the Django1.6.

I have installed postgresql, psycopg2 and Django.

my code : settings.py :

 DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': os.path.join(BASE_DIR, 'db.psycopg3'),
        'USER': 'root',
        'PASSWORD': 'root',
        'HOST': '127.0.0.1',
        'PORT': '5432',
         }
   }

and to python manage.py shell :

from django.db import connection
cursor = connection.cursor()

Errors :

FATAL:  password authentication failed for user "root"

Please help...

有帮助吗?

解决方案

The database name in your settings.py should be modified. Actually you had entered the format used for sqlite db. For postgres, it should be

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'NAME': 'dbname',
    'USER': 'root',
    'PASSWORD': 'rootXXX',
    'HOST': '',
    'PORT': '',
}
}

Create the Database 'dbname' in your postgres before synchronizing it with your app

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top