0

Switching from user "postgres", I created a new Postgres user and changed my Django project to make use of this new user / credentials:

sudo -u postgres -i
psql -c "CREATE USER foo WITH PASSWORD 'xxxxxxxxxxxx' CREATEDB;"
psql -c "GRANT ALL PRIVILEGES ON DATABASE bar TO foo;"

In settings for Django:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'bar',
        'USER': 'foo',
        'PASSWORD': 'xxxxxxxxxxxx',
        'HOST': 'localhost',
        'ATOMIC_REQUESTS': True
    }
}

But I get the error when using "python manage.py runserver":

django.db.utils.ProgrammingError: permission denied for relation django_migrations
7
  • And you ran python manage.py migrate? Did it give the same error?
    – csinchok
    Oct 3, 2016 at 19:29
  • @PopcornArsonist yes, the exact same error. Although I don't need to run "migrate" as the database is already up to date with the migrations. This is not a new installation, previously I was using user "postgres".
    – gornvix
    Oct 3, 2016 at 19:34
  • 1
    I found another question that seems to be related to this issue. Maybe try the answer from that: stackoverflow.com/a/12236582/931098 (just the GRANT steps, of course)
    – csinchok
    Oct 3, 2016 at 19:37
  • Have you added the user to the postgres pg_hba.conf? Oct 3, 2016 at 19:44
  • 1
    Yes, you probably need that in order to create new tables.
    – csinchok
    Oct 3, 2016 at 21:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.