Opened 10 years ago

Closed 10 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


Invalid field values when you use select_related() and defer().
See sample below.
May be it clashes with ticket #11606

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' %
class Work(models.Model):
    name = models.CharField(max_length=20, default='work')
    author = models.ForeignKey(Author)   
    def __unicode__(self):
        return u'%s' % shell

from test.myapp.models import *
a = Author()
w = Work() = a
w = Work.objects.filter(id=1).select_related('author').defer('author__text1')[0]
>> u'text2'  !!! ERROR

Change History (2)

comment:1 Changed 10 years ago by drdaeman

Possibly, the same bug as in #10733?

comment:2 Changed 10 years ago by Russell Keith-Magee

Resolution: duplicate
Status: newclosed

Closing as a duplicate of #11606, as the reporter suggested.

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