OperationalError, no such column. Django

后端 未结 22 1671
情话喂你
情话喂你 2020-12-24 00:45

I am very new to django and was able to finish the tutorial on djangoproject.com without any errors. I am now going through the Django REST framework tutorial found at http:

相关标签:
22条回答
  • 2020-12-24 01:14

    I faced this problem and this is how I solved it.

    1) Delete all the migration records from your app's migration directory. These are files named 0001_,0002_,0003_ etc. Be careful as to not delete the _init__.py file.

    2) Delete the db.sqlite3 file. It will be regenerated later.

    Now, run the following commands:

    python manage.py makemigrations appname
    python manage.py migrate
    

    Be sure to write the name of your app after makemigrations. You might have to create a superuser to access your database again. Do so by the following

    python manage.py createsuperuser
    
    0 讨论(0)
  • 2020-12-24 01:14

    I did the following

    1. Delete my db.sqlite3 database
    2. python manage.py makemigrations
    3. python manage.py migrate

    It renewed the database and fixed the issues without affecting my project. Please note you might need to do python manage.py createsuperuser because it will affect all your objects being created.

    0 讨论(0)
  • 2020-12-24 01:16

    In my case, in admin.py I was querying from the table in which new ForeignKey field was added. So comment out admin.py then run makemigrations and migrate command as usual. Finally uncomment admin.py.

    0 讨论(0)
  • 2020-12-24 01:16

    You did not migrated all changes you made in model. so 1) python manage.py makemigrations 2) python manage.py migrate 3) python manag.py runserver it works 100%

    0 讨论(0)
  • 2020-12-24 01:16

    I simple made a careless mistake of forgetting to actually apply the migration (migrate) after making migrations. Writing this just in case anyone might make the same mistake.

    0 讨论(0)
  • 2020-12-24 01:16

    I think you skipped this steps...run the following commands to see if you had forgotten to execute them...it worked for me.

    $ python manage.py makemigrations

    $ python manage.py migrate

    Thank you.

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