问题
Can someone give a detailed explanation on how to fix the ERROR: no such table: main.auth_user__old
It arises in my Django application when I am trying to add data to my registered models.
回答1:
It's a compatibility issue between latest SQLite and Django. See here: Django - No such table: main.auth_user__old
回答2:
I have solved this issue using below :
1) Delete the db.sqlit3
2) app's directory delete everything in pycache
3) manage.py makemigrations, manage.py migrate, manage.py createsuperuser and then manage.py runserver.
回答3:
You probably haven't run the migrations. Until you run migrations, no tables are created. Hence the error. See https://docs.djangoproject.com/en/2.1/topics/migrations/#workflow
After you've registered your models, go to your git bash or powershell. Make sure you are in your project directory. Then run these commands :
python manage.py makemigrations
And then
python manage.py migrate
These commands will create tables for you and then you can add data to them.
来源:https://stackoverflow.com/questions/54070355/how-to-fix-no-such-table-main-auth-user-old