Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: OperationalError at /admin/

Tags:

python

django

So I ran my program based on from here and It worked without any error. I go to to /admin. I login. So far everything is good. Then when it loads I get this:

Error Code

I checked the traceback (which is really long) and none of includes my code. It doesn't tell me what part of the code this error is occurring in so I don't know how to approach this. Please explain what this is, why this is happening, and how I can fix it.

If you need any part of my code, just ask in comments because I don't know where this is happening.

like image 411
ansg191 Avatar asked Mar 21 '16 04:03

ansg191


Video Answer


3 Answers

You need to run migrate command in-order to force django to create auth tables.

python manage.py migrate

Then for any change you made on models, don't forget to run these two commands.

python manage.py makemigrations
python manage.py migrate
like image 118
Avinash Raj Avatar answered Oct 08 '22 03:10

Avinash Raj


Use pip install django==2.1.5

If the problem persists,

Use python manage.py migrate --run-syncdb

like image 40
Sushant Raj Thapa Avatar answered Oct 08 '22 03:10

Sushant Raj Thapa


  • by default, the auth table is not created in the database
  • so first we need to create the table and reload the page

to achieve the same

make the migrations by typing the following command

        1. python3 manage.py makemigrations
        2. python3 manage.py migrate
like image 39
achyuth Avatar answered Oct 08 '22 02:10

achyuth