#27232: Regression in construct_instance for FileField's with defaults
---------------------------------+--------------------
     Reporter:  ryanbutterfield  |      Owner:  nobody
         Type:  Bug              |     Status:  new
    Component:  Forms            |    Version:  1.10
     Severity:  Normal           |   Keywords:
 Triage Stage:  Unreviewed       |  Has patch:  0
Easy pickings:  1                |      UI/UX:  0
---------------------------------+--------------------
 Django 1.10 has added a regression in construct_instance in relation to
 FileField's with a default value (or any field that uses form.files).

 This was added in
 
https://github.com/django/django/commit/325dd0befea3012c42eefa061f509fbdf1b6a8aa
 and a separate regression fixed in
 
https://github.com/django/django/commit/db3eabfae5c590801a74e0b318663b6480145fb9

 The new code only checks for {{{form.add_prefix(f.name) not in
 form.data}}}. FileField's have their values in {{{form.files}}} and not in
 {{{form.data}}}, so this causes FileField's to be skipped if
 {{{f.has_default()}}} is True.

 The correct code should be along the lines of:

 {{{
  if (f.has_default() and
                   form.add_prefix(f.name) not in form.data and
                   form.add_prefix(f.name) not in form.files and
                   not getattr(form[f.name].field.widget,
 'dont_use_model_field_default_for_empty_data', False)):
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27232>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/058.c094d748b10c96c0f949b8174e4c1cd1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to