python - Django : Syncdb incorrectly warns that many-to-many field is stale

标签 python django django-models django-admin django-authentication

我有一个 Django 应用程序,其中一个应用程序与 UserProfile 具有多对多关系。但是每当我执行 syncdb 时,它都会警告我 app_users 是陈旧的字段

The following content types are stale and need to be deleted:
     Apps | app_users

#settings.py
AUTH_PROFILE_MODULE = 'kprofile.UserProfile'

#Apps/models.py
class app(models.Model):
    ....
    users = models.ManyToManyField(UserProfile)

现在我不在 View 内使用 UserProfile,除非在规则内用于某些身份验证目的。并且 UserProfile 只能从管理界面附加到应用程序。我怎样才能阻止 django syncdb 给我这个错误/不正确的警告?

最佳答案

注意消息。这并不是说您的领域已经过时 - 它是在谈论 Content Types 中的一个条目模型。

在 shell 中,执行此操作:

from django.contrib.contenttypes.models import ContentType
ct = ContentType.objects.get(app_label='Apps', model='app_users')
ct.delete()

关于python - Django : Syncdb incorrectly warns that many-to-many field is stale,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5510843/

相关文章:

Python - 相交的字符串

将多个类实例属性声明为数字的 pythonic 方法?

python - 在 Python 提示符处引发错误后如何获取最后一个异常对象?

python - Django 自定义管理仪表板错误

python - Django 休息 : get_queryset providing duplicate responses

python - 带有 rbf 内核的前 10 个功能 SVC

python - 导入错误: cannot import name widgets from django. contrib.admin

python - 在 Django 中扩展模型的正确方法

python - 如何在 Django 中分别获取当前日期和当前时间?

python - models.py 越来越大,最好的方法是什么?