Opened 13 years ago
Last modified 11 years ago
#19774 closed Cleanup/optimization
contentypes generic module has core functionality plus admins-specific one — at Initial Version
| Reported by: | Ramiro Morales | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.contenttypes | Version: | dev |
| Severity: | Normal | Keywords: | dependency generic contenttypes |
| Cc: | loic@…, Simon Charette | Triage Stage: | Ready for checkin |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
(Copied from https://code.djangoproject.com/ticket/16368#comment:16)
The django/contrib/contenttypes/generic.py modules contains both the definitions of the model-related generic stuff (GenericForeignKey, etc.) AND the admin app-related specialized inlines (GenericInlineModelAdmin, GenericStackedInline, GenericTabularInline.)
So, for example, if you import django.contrib.contenttypes.generic from your models.py because you need GenericForeignKey then the !GenericXInlineY sutff imports django.contrib.admin and it in its own turn imports contrib.sites causing the reported failure (see below). Again, the Sites framework isn't listed in INSTALLED_APPS and what is worse: The admin app isn't either (!).
Maybe it's time we move GenericInlineModelAdmin, GenericStackedInline, GenericTabularInline from django.contrib.contenttypes.generic to, say, django.contrib.contenttypes.generic_admin? (of course this would need a deprecation process)
from django.contrib.contenttypes import generic
File "django/contrib/contenttypes/generic.py", line 14, in <module>
from django.contrib.admin.options import InlineModelAdmin, flatten_fieldsets
File "django/contrib/admin/__init__.py", line 6, in <module>
from django.contrib.admin.sites import AdminSite, site
File "django/contrib/admin/sites.py", line 4, in <module>
from django.contrib.admin.forms import AdminAuthenticationForm
File "django/contrib/admin/forms.py", line 4, in <module>
from django.contrib.auth.forms import AuthenticationForm
File "django/contrib/auth/forms.py", line 10, in <module>
from django.contrib.sites.models import get_current_site
File "/django/contrib/sites/models.py", line 5, in <module>
raise Exception