contrib.contenttypes.generic importing from contrib.admin causing trouble

31 views
Skip to first unread message

Jens Ådne Rydland

unread,
Nov 5, 2012, 9:30:55 AM11/5/12
to django-d...@googlegroups.com
Not really sure what to use as subject here, or whether this qualifies
to be called a bug, but I don't think it belongs on django-users due to
being an issue in Django itself so I figured I'd ask here before opening
a ticket.

So, we have a project that doesn't use contrib.auth, and it doesn't use
contrib.admin, it does, however, use contrib.contenttypes.generic. And
c.c.generic imports InlineModelAdmin and flatten_fieldsets from
contrib.admin.options, which does some more imports which down the line
causes various models to be imported from contrib.auth.models, and this
in turn causes the auth models to be registered in AppCache, and thus to
be found by db.models.Options' get_all_related_objects() which is used
by db.models.deletion.Collector.collect().

This hasn't caused us any trouble so far, but now that we needed to
delete some stale ContentTypes we suddenly got weird crashes related to
contrib.auth tables not existing when delete() tried to find foreign
keys pointing to ContentType.

I've tested moving the admin related bits from contenttypes/generic.py
to contenttypes/admin.py, which seems to have fixed our immediate
problem, but haven't really tested if it breaks anything else. And I
guess this could be considered a too obscure corner case to care about,
but would appreciate some feedback anyway.


--
Jens Ådne Rydland

Florian Apolloner

unread,
Nov 5, 2012, 5:52:59 PM11/5/12
to django-d...@googlegroups.com
Hi Jens,

does https://code.djangoproject.com/ticket/15654 describe what you see? From my understanding it seems to be the same bug, patches welcome ;)

Cheers,
Florian
Reply all
Reply to author
Forward
0 new messages