How to fix-no such table: main.auth_user__old

十年热恋 提交于 2019-12-20 07:38:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!