I am learning to user PostgreSQL
and Django
together in Ubuntu 11.10, and I have found that I need to switch to the user I created when I installed PostgreSQL ("postgres"
) in the Terminal (via "sudo su postgres"
) in order to create and then access databases to work with in Django. Unfortunately, the "postgres"
user doesn't have file writing privileges on my local file system, so when I try to do certain things like add model objects to the database that have an image field, I'm blocked. But if I switch to my normal Ubuntu user name in the Terminal and try to access my admin site on Django's dev server, I get an error like this:
OperationalError at /admin/
FATAL: Peer authentication failed for user "postgres"
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.3.1
Exception Type: OperationalError
Exception Value:
FATAL: Peer authentication failed for user "postgres"
Exception Location: /usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2/base.py in _cursor, line 140
Python Executable: /usr/bin/python
Python Version: 2.7.2
I'm trying to read up on the PostgreSQL docs to give my normal user access to the databases I've created for my Django projects, but I can't figure it out because I don't understand the relationship between PostgreSQL roles/users and Ubuntu users. Could someone please explain to me how I can give my normal Ubuntu username access to my databases in PostgreSQL? I will probably need a specific list of instructions as I've tried to piece it together using the PostgreSQL docs and I'm totally lost.