0

I am trying to switch my django database from sqlite to postgres on my local machine. I am getting the following error when I try to run python manage.py migrate

  File "/Users/omarjandali/anaconda3/envs/splittapp/lib/python3.7/site-packages/django/db/backends/postgresql/base.py", line 24, in <module>
    raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named 'psycopg2'

Now I did make changes to the settings.py file in order to switch it from the sqlite3 database to the postgres database. My code looks like this.

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'splitt', 'USER': 'splittadmin', 'PASSWORD': '*****', 'HOST': 'localhost', 'PORT': '5432', } }

This is is what the databse looks like insode of the postgres shell

splitt | splittadmin | UTF8 | en_US.UTF-8 | en_US.UTF-8 |

I was also looking up how to grand all rpivileges of a database to a superuser and I was getting mixed results.

2 Answers 2

1

Try to install psycopg2:

pip install psycopg2
Sign up to request clarification or add additional context in comments.

1 Comment

do you know how I can now create a superuser within the new django - postgresql database so I can login to the admin site.
1

Have you installed psycopg2 in your virtual environment?

#in a terminal 
pip install psycopg2

2 Comments

do you know how I can now create a superuser within the new django - postgresql database so I can login to the admin site.
You need to make a new post asking that. it sounds like a really common question, perhaps you’ll find an answer faster if you simply google it

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.