contentypes generic module has core functionality plus admins-specific one
|Reported by:||ramiro||Owned by:||ramiro|
|Severity:||Normal||Keywords:||dependency generic contenttypes|
|Cc:||loic@…, charettes||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Description (last modified by ramiro)
(Copied and adapted from https://code.djangoproject.com/ticket/16368#comment:16)
Consider a project with a foo and a bar apps listed on INSTALLED_APPS:
- foo uses generic foreign keys, with the following models.py:
from django.db import models from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import generic class TaggedItem(models.Model): tag = models.SlugField() content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey()
- bar has a Site model:
from django.db import models class Site(models.Model): name = models.CharField(... # ...
- Neither the admin nor sites Django apps are being used.
This causes the user's Site model to be overridden and masked by Django sites framework's one.
This is because the django/contrib/contenttypes/generic.py module contain both the definitions of the model-related generic stuff (GenericForeignKey, etc.) AND the admin app-related specialized inlines (GenericInlineModelAdmin, GenericStackedInline, GenericTabularInline.)
Maybe 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.
Change History (12)
comment:1 Changed 17 months ago by wim@…
- Keywords dependency generic contenttypes added
- Triage Stage changed from Unreviewed to Accepted
- Type changed from Bug to Cleanup/optimization
comment:2 Changed 16 months ago by ramiro
- Description modified (diff)
- Owner changed from nobody to ramiro
- Status changed from new to assigned
comment:6 Changed 6 months ago by charettes
- Has patch set
- Needs documentation set
- Patch needs improvement set
comment:8 Changed 6 months ago by loic84
- Needs documentation unset
- Triage Stage changed from Accepted to Ready for checkin