use*_*875 14 django django-models django-contenttypes django-migrations
这是我的models.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
Run Code Online (Sandbox Code Playgroud)
当我这样做时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
Run Code Online (Sandbox Code Playgroud)
首先,它说的很奇怪,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
Run Code Online (Sandbox Code Playgroud)
我打字了no.但这究竟是什么意思,为什么我收到这条消息,我该如何做到这一点,以便我不需要这条消息?
Rod*_*ier 11
删除/删除模型并执行迁移时会触发您收到的消息.
在大多数情况下,您可以安全地删除它们.但是,在某些情况下,这可能会导致数据丢失.如果其他模型具有已删除模型的外键,则这些对象也将被删除.
编辑
正如@ x-yuri指出的那样,这张票已被修复并已在Django 1.11中发布.
| 归档时间: |
|
| 查看次数: |
7979 次 |
| 最近记录: |