#26900: Defer FileFields causes errors when accessing them
----------------------------------------------+--------------------
     Reporter:  samuelmaudo                   |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.10
     Severity:  Release blocker               |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 The problem is in `FileDescriptor.__get__()`. That method obtains the file
 directly from `instance.__dict__` but, from Django 1.10, deferred fields
 don't create any item in `instance.__dict__`, so a KeyError is raised.

 Moreover, ImageFields access the file each time a model is instantiated to
 update dimension fields, so a KeyError is raised whenever an instance with
 a deferred ImageField is created.

 The obvious solution is change `file = instance.__dict__[self.field.name]`
 for `file = instance.__dict__.get(self.field.name)` inside of
 `FileDescriptor.__get__()` but I am not sure about the consequences.

--
Ticket URL: <https://code.djangoproject.com/ticket/26900>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/054.d567d1f21c5608fb03ae6169346b1aa8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to