这是我的模型.py:
class Notification(models.Model):
user = models.ForeignKey(User)
createdAt = models.DateTimeField(auto_now_add=True, blank=True)
read = models.BooleanField(default=False, blank=True)
class Meta:
abstract = True
class RegularNotification(Notification):
message = models.CharField(max_length=150)
link = models.CharField(max_length=100)
class FNotification(Notification):
# same as Notification
pass
当我做python manage.py makemigrations
时,它是这样说的:
Migrations for 'CApp':
0019_auto_20151202_2228.py:
- Create model RegularNotification
- Create model FNotification
- Remove field user from notification
- Add field f_request to userextended
- Delete model Notification
首先,它说Remove field user from notification
很奇怪,因为user
仍然在我的Notiication
模型中(所以如果有人能弄清楚为什么它说"从通知中删除字段用户",那就太好了!)但尽管如此,当我继续尝试python manage.py migrate
时,我收到了这样的消息:
Applying CMApp.0019_auto_20151202_2228... OK
The following content types are stale and need to be deleted:
CApp | notification
Any objects related to these content types by a foreign key will also
be deleted. Are you sure you want to delete these content types?
If you're unsure, answer 'no'.
Type 'yes' to continue, or 'no' to cancel: no
我输入了no
。但这到底意味着什么,我为什么会收到这个消息,我该如何制作它,这样我就不需要这个消息了?
删除/删除模型并进行迁移时,会触发您收到的消息。
在大多数情况下,您可以安全地删除它们。但是,在某些情况下,这可能会导致数据丢失。如果其他模型具有已删除模型的外键,则这些对象也将被删除。
这是django票证,它请求更安全地删除过时的内容类型。
编辑
正如@x-yuri所指出的,这张票已经被修复,并在Django 1.11中发布。