It seems that stale content types return `None` for 
`ContentTpye.model_class()` , so the following deletes all stale content 
types. I would back up and test this extensively first though because 
deleting content type you don't want to is dangerous.

for c in ContentType.objects.all():
   if not c.model_class():
     print "deleting %s"%c
     c.delete()

On Monday, February 11, 2013 1:13:42 AM UTC-6, vijay shanker wrote:
>
> we can delete all obsolete ContentType entries manually.
> >>>for each in ContentType.objects.filter(app_label=appname): each.delete()
>  thanks
>
> On Friday, May 4, 2007 8:42:51 PM UTC+5:30, Jens Diemer wrote:
>>
>>
>> I have delete some app models. So, in the internal django tables 
>> "django_content_type" and "auth_permission" are some old content types 
>> entries.
>>
>> So i received errors like: "ContentType matching query does not exist." 
>> (When i create a new user group).
>>
>> Is there a way to update the django tables automatically?
>>
>> -- 
>> Mfg.
>>
>> Jens Diemer
>>
>>
>> ----
>> A django powered CMS: http://www.pylucid.org
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to