Opened 10 years ago

Closed 10 years ago

#23592 closed Bug (wontfix)

Django 1.5 Proxy equality and Caching of related instances

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

Description (last modified by Cisco Guillaume)

Hello there :)

This is the first time I write a ticket regarding Django code, so I'll try to be as concise as possible.

When upgrading to django 1.5 for our company project, we ran in an unexpected behaviour.

We use a proxy model and for our needs, we use equality operator in the code.
Let's say I have a Person Model and a OrderedPerson Model which is a proxy of the Person Model.

a = Person()
b = OrderedPerson()

We have two equal objects (id and dict are similar) so b == a should be equal to True (correct in Django 1.4).
However we get:

b == a <- False
Due to this commit posted in Django 1.5 version:
File django/db/models/ Lines 327-336

In reality, it is far more complex, because we have a test like:

def __setattr__(self, name, value):
    toto = getattr(self, name, None) == value
    # some code with toto variable

I found this commit solve the problem regarding proxy equality in Django 1.7:
File django/db/models/ Lines 462-464

So we use it for our proxy models in Django 1.5

I think it could be very useful to add this piece of code, for versions from Django 1.5.


PS: I used these sources for understanding the origin of this "bug":

Change History (3)

comment:1 by Cisco Guillaume, 10 years ago

Description: modified (diff)

comment:2 by Cisco Guillaume, 10 years ago

typo fix

comment:3 by Tim Graham, 10 years ago

Resolution: wontfix
Status: newclosed

Sorry, but Django 1.5 is no longer supported per our supported versions policy and 1.6 is only receiving security fixes.

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