“no such column” after adding a field to the model

前端 未结 7 1637
抹茶落季
抹茶落季 2020-12-28 08:53

environment DJANGO VERSION 1.9 Python 2.7.6

I added a field (scores) to a model class in models.py like this

from django.db import models
from django         


        
7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-28 09:16

    Well the problem is NOT with your makemigrations command or models.py. It is because you have probably imported your class in the model (your database in this case) in on of your views.py files and the problem is with that. If you read the all of the error message then you can understand that easily.

    Just try commenting that importing part and run your python.manage.py makemigrations and python manage.py migrate commands then you can uncomment your import in your views.py file

    Hope this was useful for others as well

提交回复
热议问题