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.

Omar Jandali
  • 814
  • 3
  • 20
  • 52

2 Answers2

1

Have you installed psycopg2 in your virtual environment?

#in a terminal 
pip install psycopg2
Bruno Carballo
  • 1,156
  • 8
  • 15
  • do you know how I can now create a superuser within the new django - postgresql database so I can login to the admin site. – Omar Jandali Jan 30 '19 at 00:17
  • 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 – Bruno Carballo Jan 30 '19 at 00:25
1

Try to install psycopg2:

pip install psycopg2
Raydel Miranda
  • 13,825
  • 3
  • 38
  • 60
  • do you know how I can now create a superuser within the new django - postgresql database so I can login to the admin site. – Omar Jandali Jan 30 '19 at 00:17