OperationalError, no such column. Django

后端 未结 22 1672
情话喂你
情话喂你 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:34

    just remember there is a pycache folder hidden inside the migrations folder so if you change your models and delete all your migration files you MUST delete the pycache folder also.

    The only one you should not delete is your init file.

    Hope this helps

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

    This error can happen if you instantiate a class that relies on that table, for example in views.py.

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

    Step 1: Delete the db.sqlite3 file.

    Step 2 : $ python manage.py migrate

    Step 3 : $ python manage.py makemigrations

    Step 4: Create the super user using $ python manage.py createsuperuser

    new db.sqlite3 will generates automatically

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

    Taken from Burhan Khalid's answer and his comment about migrations: what worked for me was removing the content of the "migrations" folder along with the database, and then running manage.py migrate. Removing the database is not enough because of the saved information about table structure in the migrations folder.

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

    I see we have the same problem here, I have the same error. I want to write this for the future user who will experience the same error. After making changes to your class Snippet model like @Burhan Khalid said, you must migrate tables:

    python manage.py makemigrations snippets
    python manage.py migrate
    

    And that should resolve the error. Enjoy.

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

    The most direct way of solving this type of problem is just the following 3 steps process:

    1. Delete all the migration related files from app's migrations folder/directory (these basically starts with 0001, 0002, 0003 etc).

    2. Delete/Rename the existing database file named db.sqlite3 from App directory.

    3. Now run the following command:

      python manage.py migrate

      Finally execute

      python manage.py createsuperuser

      to perform the administrative tasks (If you want).

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