Opened 16 years ago
Closed 16 years ago
#11844 closed (duplicate)
Select_related() and defer()
| Reported by: | krylatij | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 1.1 |
| Severity: | Keywords: | selected_related, defer | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Invalid field values when you use select_related() and defer().
See sample below.
May be it clashes with ticket #11606
#models.py
class Author(models.Model):
name = models.CharField(max_length=20, default='author')
text1 = models.CharField(default='text1', max_length=10)
text2 = models.CharField(default='text2', max_length=10)
def __unicode__(self):
return u'%s' % self.name
class Work(models.Model):
name = models.CharField(max_length=20, default='work')
author = models.ForeignKey(Author)
def __unicode__(self):
return u'%s' % self.name
#manage.py shell
from test.myapp.models import *
a = Author()
a.save()
w = Work()
w.author = a
w.save()
w = Work.objects.filter(id=1).select_related('author').defer('author__text1')[0]
print w.author.text1
>> u'text2' !!! ERROR
Change History (2)
comment:1 by , 16 years ago
comment:2 by , 16 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |
Closing as a duplicate of #11606, as the reporter suggested.
Note:
See TracTickets
for help on using tickets.
Possibly, the same bug as in #10733?