3

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.

11
  • your database name is incorrect. check it
    – Debendra
    Feb 11, 2020 at 20:18
  • 1
    one useful debugging step here would be to try to connect to the database manually via cli - you should be able to do it like so: sudo -u postgres psql -d jobzumoDB -U admin -W 123
    – nthall
    Feb 11, 2020 at 20:18
  • @nthall returns psql: FATAL: Peer authentication failed for user "admin"
    – Justin
    Feb 11, 2020 at 20:25
  • @nthall I started with a youtube tutorial where I created a user 'justin' and this 'admin' user for some reason so I feel I might have screwed up and should start from the beginning only trying to follow digital oceans resources
    – Justin
    Feb 11, 2020 at 20:26
  • 1
    @nthall there it is listed as 'jobzumodb' not 'jobzumoDB'! After changing that in settings.py makemigrations worked without a problem. Thank you, you've been tremendously helpful. If I wanted to learn more do I just need to read into postgres db? These are all commands I am unfamiliar with.
    – Justin
    Feb 11, 2020 at 20:36

2 Answers 2

5

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";

1
  • 1
    amazing! Spent a lot of time before I found this. Thanks @nthall
    – MattG
    Jun 17, 2020 at 20:41
0

Use:

NAME': 'jobzumodb',

Instead of:

NAME': 'jobzumoDB',

1
  • Please write your answer in lowercase. and this answer has been already given by nthall Nov 23, 2022 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.