I ran these lines from "python manage.py shell":
from django.db import connection
cursor = connection.cursor()
But got the following error:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 306, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2/base.py", line 177, in _cursor
self.connection = Database.connect(**conn_params)
File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 179, in connect
connection_factory=connection_factory, async=async)
OperationalError: FATAL: role "jay" does not exist
In settings.py I have
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'mysite',
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}
}
What am I doing wrong here? I installed postgresql and the adapter
FATAL: role "jay" does not exist
Since USER
is blank, it's using whatever your local username is (jay
), and you haven't created a PostgreSQL user by that name.
Try:
psql -u postgres createuser -P jay
You'll probably have to put the password you enter at the prompt into settings.py
, unless your pg_hba.conf
is using ident
as the auth method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With