Changes between Initial Version and Version 2 of Ticket #19774

03/28/2013 09:16:53 PM (3 years ago)


  • Ticket #19774

    • Property Status changed from new to assigned
    • Property Owner changed from nobody to ramiro
    • Property Keywords dependency generic contenttypes added
    • Property Type changed from Bug to Cleanup/optimization
    • Property Triage Stage changed from Unreviewed to Accepted
  • Ticket #19774 – Description

    initial v2  
    1 (Copied from
     1(Copied and adapted from
    3 The django/contrib/contenttypes/ modules contains both the definitions of the model-related generic stuff (!GenericForeignKey, etc.) AND the admin app-related specialized inlines (!GenericInlineModelAdmin, !GenericStackedInline, !GenericTabularInline.)
     3Consider a project with a `foo` and a `bar` apps listed on `INSTALLED_APPS`:
     4* `foo` uses generic foreign keys, with the following ``:
     6from django.db import models
     7from django.contrib.contenttypes.models import ContentType
     8from django.contrib.contenttypes import generic
    5 So, for example, if you import `django.contrib.contenttypes.generic` from your 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 (!).
     10class TaggedItem(models.Model):
     11    tag = models.SlugField()
     12    content_type = models.ForeignKey(ContentType)
     13    object_id = models.PositiveIntegerField()
     14    content_object = generic.GenericForeignKey()
    7 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)
     17* `bar` has a `Site` model:
     19from django.db import models
    9 {{{
    10     from django.contrib.contenttypes import generic
    11   File "django/contrib/contenttypes/", line 14, in <module>
    12     from django.contrib.admin.options import InlineModelAdmin, flatten_fieldsets
    13   File "django/contrib/admin/", line 6, in <module>
    14     from django.contrib.admin.sites import AdminSite, site
    15   File "django/contrib/admin/", line 4, in <module>
    16     from django.contrib.admin.forms import AdminAuthenticationForm
    17   File "django/contrib/admin/", line 4, in <module>
    18     from django.contrib.auth.forms import AuthenticationForm
    19   File "django/contrib/auth/", line 10, in <module>
    20     from django.contrib.sites.models import get_current_site
    21   File "/django/contrib/sites/", line 5, in <module>
    22     raise Exception
     21class Site(models.Model):
     22    name = models.CharField(...
     23    # ...
     25* Neither the admin nor sites Django apps are being used.
     27This causes the user's Site model to be overridden and masked by Django sites framework's one.
     29This is because the `django/contrib/contenttypes/` module contain both the definitions of the model-related generic stuff (!GenericForeignKey, etc.) AND the admin app-related specialized inlines (!GenericInlineModelAdmin, !GenericStackedInline, !GenericTabularInline.)
     31Maybe it's time we move the latter ones from `django.contrib.contenttypes.generic` to, say, a new `generic_admin` (or `admin_tools`?) on `django.contrib.contenttypes`?. Of course this would need a deprecation process.
Back to Top