delete obsolete content type entries...

1,573 views
Skip to first unread message

Jens Diemer

unread,
May 4, 2007, 11:12:51 AM5/4/07
to django...@googlegroups.com

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

Jens Diemer

unread,
May 7, 2007, 4:32:45 AM5/7/07
to django...@googlegroups.com
That surprises me. Does nobody have the same problems?
Still nobody delete a model class?

How to clean up the django tables? With phpMyAdmin?

Jens Diemer

unread,
May 8, 2007, 7:59:37 AM5/8/07
to django...@googlegroups.com

Here a stand alone cleanup script, for discussion:

http://paste.pocoo.org/show/1482/


btw. you should have the same problem, if you test a separate django
app. And "deinstall" it later.

If you use "django.contrib.auth" and "django.contrib.contenttypes" there
must be exist obsolete contenttypes and permission entries, after you
deactivate the test-App.

Gabriel Farrell

unread,
Jun 18, 2007, 2:52:56 PM6/18/07
to Django users
On May 7, 4:32 am, Jens Diemer <python_gm...@jensdiemer.de> wrote:
> That surprises me. Does nobody have the same problems?
> Still nobody delete a model class?
>
> How to clean up the django tables? With phpMyAdmin?
>

I've just run into a similar issue when I removed an app from a
project. After some attempt to fix the tables myself, I held my
breath, dropped the tables (auth_permission and django_content_type),
then ran "python manage.py syncdb". Voila, the tables were re-created
correctly, without the app I had removed.

Jens Diemer

unread,
Jun 19, 2007, 7:53:10 AM6/19/07
to django...@googlegroups.com
Gabriel Farrell schrieb:

> On May 7, 4:32 am, Jens Diemer <python_gm...@jensdiemer.de> wrote:
>> That surprises me. Does nobody have the same problems?
>> Still nobody delete a model class?
>>
>> How to clean up the django tables? With phpMyAdmin?
>>
>
> I've just run into a similar issue when I removed an app from a
> project. After some attempt to fix the tables myself, I held my
> breath, dropped the tables (auth_permission and django_content_type),
> then ran "python manage.py syncdb". Voila, the tables were re-created
> correctly, without the app I had removed.

Yes, you can drop and recreate the tables.
But if you setup users and permissions, then IMHO you lost this :(

For PyLucid i have made a small tool to fix this:
http://pylucid.net/trac/browser/branches/0.8%28django%29/PyLucid/tools/clean_tables.py?rev=1085

vijay shanker

unread,
Feb 11, 2013, 2:13:42 AM2/11/13
to django...@googlegroups.com, python...@jensdiemer.de
we can delete all obsolete ContentType entries manually.
>>>for each in ContentType.objects.filter(app_label=appname): each.delete()
 thanks
Reply all
Reply to author
Forward
0 new messages