12

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?

Neo
  • 13,179
  • 18
  • 55
  • 80

1 Answers1

20

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()
Olivier Pons
  • 15,363
  • 26
  • 117
  • 213
Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
  • Followed your commands and printed ct. ct => . I would think that is a valid relationship. – Neo Apr 01 '11 at 09:04
  • Nothing to do with whether it's valid. That CT no longer points to the correct place. Delete it and run syncdb, which will recreate it properly. – Daniel Roseman Apr 01 '11 at 09:09
  • 2
    I took a deep breath(i'm working directly on production server) and typed "yes" at the prompt. Apparently everything is still working correctly. Thanks for clarifying. – Neo Apr 01 '11 at 09:34
  • 1
    If you need a silent statement that doesn't throw exceptions: `ContentType.objects.filter(app_label='Apps', model='app_users').delete()` – Cloud Artisans Aug 05 '13 at 22:56