請幫忙,發生一些奇怪的事情。如何更改模型後更改數據庫?
我做了一個模型:
class Feedback(models.Model):
username = models.CharField(
verbose_name=u"Имя",
max_length=100,
blank=True,
)
subject = models.CharField(
verbose_name=u"Тема",
max_length=100,
blank=False,
)
email = models.EmailField(
verbose_name=u"Email",
max_length=100,
blank=True,
)
message = models.TextField(
verbose_name=u'Сообщение',
max_length=50000,
blank=False,
)
date = models.DateTimeField(
verbose_name=u'Дата создания',
default=datetime.now(),
auto_now=True,
)
此基礎上,我創建了一個反饋表。她工作。我創建了一些消息,然後刪除相應的表中的所有條目的數據庫
然後,我改變了字段的名稱:
class Feedback(models.Model):
username_f = models.CharField(
verbose_name=u"Имя",
max_length=100,
blank=True,
)
subject_f = models.CharField(
verbose_name=u"Тема",
max_length=100,
blank=False,
)
email_f = models.EmailField(
verbose_name=u"Email",
max_length=100,
blank=True,
)
message_f = models.TextField(
verbose_name=u'Сообщение',
max_length=50000,
blank=False,
)
date_f = models.DateTimeField(
verbose_name=u'Дата создания',
default=datetime.now(),
auto_now=True,
)
並提出從控制檯執行以下操作:
(kinopom_env)[email protected] ~/.virtualenvs/kinopom_project/kinopom $ python manage.py schemamigration --auto app_menu
將得到以下結果:
- Deleted field username on app_menu.Feedback
- Deleted field date on app_menu.Feedback
? The field 'Feedback.message' does not have a default specified, yet is NOT NULL.
? Since you are removing this field, you MUST specify a default
? value to use for existing rows. Would you like to:
? 1. Quit now.
? 2. Specify a one-off value to use for existing columns now
? 3. Disable the backwards migration by raising an exception; you can edit the migration to fix it later
? Please select a choice:
請幫忙糾正ŧ他的情況,並解釋發生了什麼