﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
27232	Regression in construct_instance for FileField's with defaults	ryanbutterfield	nobody	"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)):
}}}


"	Bug	closed	Forms	1.10	Normal	duplicate			Unreviewed	0	0	0	0	1	0
