#27232 closed Bug (duplicate)
Regression in construct_instance for FileField's with defaults
Reported by: | ryanbutterfield | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 1.10 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
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)):
Change History (1)
comment:1 by , 8 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Duplicate of #27186, should be fixed in Django 1.10.1 by this patch.