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

ⅰ亾dé卋堺 提交于 2019-12-05 17:22:43

问题


I have a django application where one application has many-to-many relationship with a UserProfile. But whenever I do a syncdb, it warns me that app_users is stale field

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)

Now I don't use UserProfile inside view except for some authentication purposes inside rules. And a UserProfile can be attached to an App only from admin interface. How can I stop django syncdb from giving me this false/incorrect warning?


回答1:


Pay attention to the message. It's not claiming that your field is stale - it's talking about an entry in the Content Types model.

In the shell, do this:

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


来源:https://stackoverflow.com/questions/5510843/django-syncdb-incorrectly-warns-that-many-to-many-field-is-stale

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!