Opened 10 years ago

Closed 10 years ago

Last modified 9 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

Description

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 by Loic Bistuer, 10 years ago

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 by Adam Johnson, 10 years ago

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 by Loic Bistuer, 10 years ago

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

comment:5 by Tim Graham, 10 years ago

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 by GitHub <noreply@…>, 10 years ago

Resolution: fixed
Status: newclosed

In d4eefc7e:

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

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

In 21f18e53:

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

Backport of d4eefc7e2af0d93283ed1c03e0af0a482982b6f0 from master

comment:8 by Jacob Rief, 9 years ago

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