ansg191
ansg191

Reputation: 439

Django: OperationalError at /admin/

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.

Upvotes: 10

Views: 38075

Answers (12)

Thành Trần
Thành Trần

Reputation: 1

I delete my db.sqlite and rerun the migrations and migrate

Upvotes: 0

Mahdi
Mahdi

Reputation: 1

Just delete the sqlite database and migrations files then run this

python manage.py makemigrations python manage.py migrate

Upvotes: -1

Rishi G
Rishi G

Reputation: 1

use these commands

python3 manage.py makemigrations

python3 manage.py migrate

python3 manage.py runserver

Upvotes: -1

rajoalivelo
rajoalivelo

Reputation: 1

user permission

Hi In Django Administration :check if the user has the right permission, it should work

Upvotes: -1

Aahad
Aahad

Reputation: 577

this is the problem with migration just type the following command:-

python manage.py migrate

Upvotes: 0

Mayunga6
Mayunga6

Reputation: 21

Install latest django version

$ pip3 install django==2.2.8
$ python3 manage.py makemigrations
$ python manage.py migrate

then reload page in browser

Upvotes: 0

achyuth
achyuth

Reputation: 11

  • 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

Upvotes: 1

Sushant Raj Thapa
Sushant Raj Thapa

Reputation: 21

Use pip install django==2.1.5

If the problem persists,

Use python manage.py migrate --run-syncdb

Upvotes: 2

i_m_brunda
i_m_brunda

Reputation: 1

yes, that was fault of django version ,when i installed django==2.1.5 that problem was solved.

Upvotes: 0

Tms91
Tms91

Reputation: 4154

If you still get error after you lunched

python manage.py migrate

and for every change you made on models

python manage.py makemigrations
python manage.py migrate

Then check if you have Django version older than 2.1.5, because this latter version fixes a bug returning "OperationalError>no such table" when adding an object to your database as superuser. So try to

pip install Django==2.1.5

However, you will have to re-write your project anew.

Upvotes: -1

Mohammad Fraz
Mohammad Fraz

Reputation: 69

Till the time they don't debug this issue with Django and Sqlite3 use the older versions of Django You may consider using version 1.10.5(using command pip install --upgrade django==1.10.5)

Upvotes: 0

Avinash Raj
Avinash Raj

Reputation: 174696

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

Upvotes: 24

Related Questions