Opened 15 years ago
Closed 15 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 |
Description
If I have a proxy of a model, the related manager does not correctly limit related items.
E.g.
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() 1000 >>> p = Profile.objects.get( pk = 1234 ) >>> p.locations.count() 1 >>> pp = ProxyProfile.objects.get( pk = 1234 ) >>> pp.locations.count() 1000
Note:
See TracTickets
for help on using tickets.
Opps... this is actually a manifestation of #10808
(Not mentioned in description is that example "Profile" object actually has two base classes.)
Closing ....