Code

Opened 4 years ago

Closed 4 years ago

#13789 closed (invalid)

related manager does not limit correctly on a proxy model

Reported by: shauncutts 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: UI/UX:

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

Attachments (0)

Change History (1)

comment:1 Changed 4 years ago by shauncutts

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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

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

Closing ....

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.