OperationalError, no such column. Django

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

    I had this problem recently, even though on a different tutorial. I had the django version 2.2.3 so I thought I should not have this kind of issue. In my case, once I add a new field to a model and try to access it in admin, it would say no such column. I learnt the 'right' way after three days of searching for solution with nothing working. First, if you are making a change to a model, you should make sure that the server is not running. This is what caused my own problem. And this is not easy to rectify. I had to rename the field (while server was not running) and re-apply migrations. Second, I found that python manage.py makemigrations captured the change as opposed to just python manage.py makemigrations. I don't know why. You could also follow that up with python manage.py migrate . I'm glad I found this out by myself.

提交回复
热议问题