Opened 9 years ago

Closed 9 years ago

#13789 closed (invalid)

related manager does not limit correctly on a proxy model

Reported by: Shaun Cutts Owned by: nobody
Component: Database layer (models, ORM) Version: 1.2
Severity: Keywords:
Cc: shaun@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


If I have a proxy of a model, the related manager does not correctly limit related items.


class Profile( models.Model ):

 # ...

class Location( models.Model ):
    home_of = models.ForeignKey( Profile, related_name= 'locations' )

class ProxyProfile( Profile ):
    class Meta:
        proxy = True

Now if I have a particular Profile p with one location, its related manager
will give me the correct number of objects, but not when accessed via the proxy:

>>> Location.objects.count()
>>> p = Profile.objects.get( pk = 1234 )
>>> p.locations.count()
>>> pp = ProxyProfile.objects.get( pk = 1234 )
>>> pp.locations.count()

Change History (1)

comment:1 Changed 9 years ago by Shaun Cutts

Resolution: invalid
Status: newclosed

Opps... this is actually a manifestation of #10808

(Not mentioned in description is that example "Profile" object actually has two base classes.)

Closing ....

Note: See TracTickets for help on using tickets.
Back to Top