简体   繁体   中英

Difficulty opening port 5432 for PostgreSQL on Ubuntu 12.04

I'm trying to get a postgres database talking to a django installation.

I've followed the steps details here: http://blog.iiilx.com/programming/how-to-install-postgres-on-ubuntu-for-django/

However, when I use syncdb to have django update my postgres database, I receive the following error:

connection_factory=connection_factory, async=async)
django.db.utils.OperationalError: FATAL:  database "/home/flowcore/django_db" 
does not exist

django_db is the name of the database and it DOES exist but of course it doesn't exist at /home/flowcore/django_db (that is not where postgres stores data!)

My databases dict in settings.py looks like this:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': os.path.join(BASE_DIR, 'django_db'),
        'USER': 'django_login',
        'PASSWORD': 'mypasswordhere',  #obviously i've replaced this with my actual password
        'HOST': 'localhost',
    }
}

Do I have to specific an absolute path to my postgres database file and, if so, where are these files stored?

Well, for some reason you have put the full path as the NAME parameter, so it's not surprising that Django is using that. There's no reason to do that, and that tutorial you link to doesn't suggest it. NAME is the database name itself, which as you say is just "django_db".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM