djangopostgresqldigital-oceandjango-databasedjango-deployment

django.db.utils.OperationalError: FATAL: database does not exist (postgres / deploy to digitalocean)


I am trying to deploy a project with digital ocean. I followed the instructions found at https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04 Some of the important ones: I ran:

postgres=# CREATE DATABASE jobzumoDB;
CREATE DATABASE

then:

postgres=# CREATE USER admin WITH PASSWORD '123';
CREATE ROLE
postgres=# GRANT ALL PRIVILEGES ON DATABASE jobzumoDB  TO admin;
GRANT

set the following in settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'jobzumoDB',
        'USER':'admin',
        'PASSWORD':'123',
        'HOST':'localhost',
        'PORT':'',
    }

then tried to run:

 ~/jobzumo/manage.py makemigrations

and got:

 File "/home/justin/jobzumo/env/lib/python3.6/site-packages/psycopg2/__init__.py", line 126, in connect
        conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
    django.db.utils.OperationalError: FATAL:  database "jobzumoDB" does not exist

Two things:

ALLOWED_HOSTS = ['jobzumo.com', '142.93.184.125']

I have not yet connect jobzumo.com to digital ocean, but the IP address was copied from my droplet.

Also, I ran: pip install django gunicorn psycopg2 (from digitial ocean)

but a tutorial on youtube said it was very important to now install psycopg2-binary instead, however, I did not do this as the video was veering far from digital ocean's tutorial.

Thanks for any help, after starting to understand django I didn't think deploying would be this much of a headscratcher.


Solution

  • Formalizing what we worked out in the comments as an answer, when you give postgres an unquoted string as an identifier, it forces it to lower-case. see this similar answer from pgsql-general mailing list. So the actual name of the database created by the command CREATE DATABASE jobzumoDB; is jobzumodb. to create a database named jobzumoDB it's necessary to use quotes, as in CREATE DATABASE "jobzumoDB";