Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#27073 closed Bug (fixed)

Overridden model managers shouldn't appear in _meta.managers

Reported by: Tim Graham Owned by: nobody
Component: Database layer (models, ORM) Version: 1.10
Severity: Release blocker Keywords:
Cc: Loic Bistuer, jacob.rief@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


The following models from the Django test suite validate on Django 1.9.x but result in this error on Django 1.10:

CustomArticle.on_site: (sites.E001) CurrentSiteManager could not find a field named 'sites'.

from django.contrib.sites.managers import CurrentSiteManager
from django.contrib.sites.models import Site
from django.db import models

class AbstractArticle(models.Model):
    on_site = CurrentSiteManager()

    class Meta:
        abstract = True

class CustomArticle(AbstractArticle):
    site_for_article = models.ForeignKey(Site, models.CASCADE)
    on_site = CurrentSiteManager('site_for_article')

Bisected to 3a47d42fa33012b2156bf04058d933df6b3082d2. CustomArticle._meta.managers shows both CurrentSiteManager instances and the one from the abstract model raises the error.

Change History (8)

comment:1 Changed 7 years ago by Loic Bistuer

I'm not sure I get it. The CustomArticle doesn't seem to have a site field, so why shouldn't the warning be raised?

comment:2 Changed 7 years ago by Adam Johnson

Perhaps the real mistake is running check() for the shadowed CurrentSiteManager from the abstract model? It's not accessible from the concrete model once it's been shadowed right?

comment:3 Changed 7 years ago by Loic Bistuer

OK got it, I missed the site_for_article part. I've got a fix in mind.

comment:5 Changed 7 years ago by Tim Graham

Has patch: set
Summary: Checks framework doesn't ignore overridden model managersOverridden model managers shouldn't appear in _meta.managers
Triage Stage: AcceptedReady for checkin

comment:6 Changed 7 years ago by GitHub <noreply@…>

Resolution: fixed
Status: newclosed

In d4eefc7e:

Fixed #27073 -- Removed duplicated managers in Model._meta.managers.

comment:7 Changed 7 years ago by Loïc Bistuer <loic.bistuer@…>

In 21f18e53:

[1.10.x] Fixed #27073 -- Removed duplicated managers in Model._meta.managers.

Backport of d4eefc7e2af0d93283ed1c03e0af0a482982b6f0 from master

comment:8 Changed 6 years ago by Jacob Rief

Cc: jacob.rief@… added
Note: See TracTickets for help on using tickets.
Back to Top