How to fix-no such table: main.auth_user__old

后端 未结 8 1317
北恋
北恋 2021-01-23 08:02

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 a

相关标签:
8条回答
  • 2021-01-23 08:05

    If you are using django==2.1 then maybe you getting this error. Just start your Django project again bu installing django==2.1.5 It will work.

    0 讨论(0)
  • 2021-01-23 08:06

    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.

    0 讨论(0)
  • 2021-01-23 08:15

    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.

    0 讨论(0)
  • 2021-01-23 08:19

    This happened to me as a newbie, whilst following Mosh's intro course on the final project 3: Django. This is the fix, usually using Pycharm or it's equivalent (no need to change any of your code):

    1. close any terminal windows in PyCharm or other 'runserver' instances
    2. delete db.sqlite3

    Then upgrade Django like this in a terminal window pip install --upgrade django==2.1.5 Once it's done, you rebuild.

    1. open a terminal window in PyCharm, type: python manage.py makemigrations and hit enter. It should say no changes detected.
    2. Then type: python manage.py migrate, it'll rebuild db.sqlite3
    3. Then: python manage.py runserver and let that run.
    4. Open a new terminal, type python manage.py createsuperuser and follow prompts.
    5. Open http://127.0.0.1:8000/admin , enter the details you just created, and you're working.
    0 讨论(0)
  • 2021-01-23 08:20

    When I used the python shell to add to database instead of the UI, error did not show anymore

    $ python manage.py shell
    

    In the python shell

    from AppName.models import Product
    Product.objects.create(title='Newer', price=239.99, summary='awesome')
    
    0 讨论(0)
  • 2021-01-23 08:22

    There is no need to downgrade to any version of Django or SQL Lite but if you follow the steps I have outlined in this GitHub link https://github.com/komerela/django_troubleshooting you should be good to go... Once you click on the pdf document labeled "Sorting the SQLITE3 issue step by step solution.pdf"

    You're welcome!

    0 讨论(0)
提交回复
热议问题