获得“以下内容类型是陈旧的,需要删除”尝试迁移时。这是什么意思,我该如何解决呢? [英] Getting a "The following content types are stale and need to be deleted" when trying to do a migrate. What does this mean, and how can I solve it?

查看:232
本文介绍了获得“以下内容类型是陈旧的,需要删除”尝试迁移时。这是什么意思,我该如何解决呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的models.py:

This is my 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

当我执行 python manage.py makemigrations 时,这就是说:

When I do python manage.py makemigrations, this is what it says:

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

首先,它表示从通知中删除字段用户,因为用户仍然是在我的通知模型(所以如果有人可以弄清楚为什么它说删除现场用户从通知,那将是伟大的!)但是,当我继续尝试 python manage.py migrate 我收到以下消息:

First, it's weird that it says Remove field user from notification because user is still in my Notiication model (so if anyone can figure out why it says that it say 'removing the field user from notification', that would be great!) but nonetheless, when I move on and try to do python manage.py migrate I get this message:

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 。但是这是什么意思,为什么我得到这个消息,我该怎么做,所以我不需要这个消息?

I typed no. But what exactly does this mean, why am I getting this message and how do I make it so that I don't require this message?

推荐答案

您删除/删除模型并进行迁移时,会触发您收到的消息。

The message you get is triggered when you remove/delete a model and do a migration.

在大多数情况下,您可以安全地删除它们。但是,在某些情况下,这可能会导致数据丢失。如果其他型号有移除型号的外键,这些对象也将被删除。

In most cases, you can delete them safely. However, in some cases this might result to data loss. If other models have a foreign key to the removed model, these objects will also be deleted.

这是django的机票,要求删除陈旧的内容类型更安全。

这篇关于获得“以下内容类型是陈旧的,需要删除”尝试迁移时。这是什么意思,我该如何解决呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆