Opened 12 years ago

Last modified 10 years ago

#19774 closed Cleanup/optimization

contentypes generic module has core functionality plus admins-specific one — at Version 2

Reported by: Ramiro Morales Owned by: Ramiro Morales
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 (last modified by Ramiro Morales)

(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 (2)

comment:1 by wim@…, 12 years ago

Keywords: dependency generic contenttypes added
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

comment:2 by Ramiro Morales, 12 years ago

Description: modified (diff)
Owner: changed from nobody to Ramiro Morales
Status: newassigned
Note: See TracTickets for help on using tickets.
Back to Top