Opened 2 years ago

Closed 2 years ago

#17678 closed Bug (fixed)

Model._meta proxy_for_model set up incorrectly

Reported by: akaariai Owned by: nobody
Component: Database layer (models, ORM) Version: 1.3
Severity: Normal Keywords:
Cc: akaariai Triage Stage: Unreviewed
Has patch: yes Needs documentation:
Needs tests: Patch needs improvement:
Easy pickings: no UI/UX: no


There are some places in the code which assume that proxy_for_model creates a proxy chain. That is, if you have models:


the expected result is that ProxyProxy._meta.proxy_for_model == Proxy, but this isn't true. One place which makes this proxy-chain mistake is the very place that sets up the proxy_for_model so this seems like a clear bug.

In the attached patch I added ._meta.concrete_class, which is always the concrete class of the model. This simplifies code in some places. In addition, the proxy_for_model correctly creates a proxy chain now.

I think the proxy_for_model error was responsible for one bug in admin, but I haven't verified that there was a bug (so, no tests). In addition there is one place in sql/ which is working now as it was before, but I am not sure if the before behavior was in fact correct. Neither of these should be this ticket's problems.

The bug is present in at least 1.3, maybe even before.

Attachments (1)

17678.diff (5.1 KB) - added by akaariai 2 years ago.

Download all attachments as: .zip

Change History (2)

Changed 2 years ago by akaariai

comment:1 Changed 2 years ago by carljm

  • Resolution set to fixed
  • Status changed from new to closed

In [17573]:

Fixed #17678 -- Corrected setup of _meta.proxy_for_model and added _meta.concrete_model. Thanks Anssi Kääriäinen.

Add Comment

Modify Ticket

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

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

Note: See TracTickets for help on using tickets.