Opened 8 years ago

Closed 8 years ago

#27186 closed Bug (fixed)

Cannot change CheckboxSelectMultiple, FileInput, MultiWidget, SplitDateTimeWidget, and SelectDateWidget with model field default since Django 1.10.1

Reported by: Michael Käufl Owned by: Tim Graham
Component: Forms Version: 1.10
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Michael Käufl)

Since Django 1.10.1 (it worked in 1.10.0), it is not possible to change the value of a DateTimeField in the admin if the field has a default.

Changing the value and saving the object results in the old value still being in the database.

How to reproduce

I created a small example project to easily reproduce the problem.

It has a model ''Dummy'' with two DateTimeFields. One with and one without a default (django.utils.timezone.now). The admin is the default django.contrib.admin.ModelAdmin.

git clone https://github.com/michael-k/datetimefieldbroken.git && cd datetimefieldbroken
docker-compose build --pull
docker-compose run web migrate
docker-compose run web createsuperuser
docker-compose up -d

Head your browser to http://localhost:8023/admin/main/dummy/add/, login and create a new Dummy using Save and continue editing. Change the values all for input fields and press Save and continue editing again. The values of Dt with default are unchanged.

Patch that introduced the issue

We believe that PR 7068 (regarding issue 27039) introduced the problem, but did not validate this. Supposedly this happens because DateTimeField is split into two fields (date + time) in the admin.

We tried it however with Django 1.10.0 and it works just fine.

Change History (13)

comment:1 by Michael Käufl, 8 years ago

Description: modified (diff)

comment:2 by Michael Käufl, 8 years ago

Description: modified (diff)

comment:3 by Tim Graham, 8 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

comment:4 by Tim Graham, 8 years ago

Owner: changed from nobody to Tim Graham
Status: newassigned

comment:5 by Tim Graham, 8 years ago

Has patch: set

comment:6 by Tim Graham, 8 years ago

Summary: Cannot change DateTimeField with default via Admin since Django 1.10.1Cannot change FileInput, MultiWidget, SplitDateTimeWidget, and SelectDateWidget with model field default since Django 1.10.1

comment:7 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: assignedclosed

In 3507d4e7:

Fixed #27186 -- Fixed model form default fallback for MultiWidget, FileInput, SplitDateTimeWidget, SelectDateWidget, and SplitArrayWidget.

Thanks Matt Westcott for the review.

comment:8 by Tim Graham <timograham@…>, 8 years ago

In 0b59ea33:

[1.10.x] Fixed #27186 -- Fixed model form default fallback for MultiWidget, FileInput, SplitDateTimeWidget, SelectDateWidget, and SplitArrayWidget.

Thanks Matt Westcott for the review.

Backport of 3507d4e773aa9ff2336e7230ba231c4ba6eb568f from master

comment:9 by Tim Graham, 8 years ago

Has patch: unset
Resolution: fixed
Status: closednew
Summary: Cannot change FileInput, MultiWidget, SplitDateTimeWidget, and SelectDateWidget with model field default since Django 1.10.1Cannot change CheckboxSelectMultiple, FileInput, MultiWidget, SplitDateTimeWidget, and SelectDateWidget with model field default since Django 1.10.1

As reported in #27291, CheckboxSelectMultiple is also affected.

comment:10 by Tim Graham, 8 years ago

Has patch: set

PR for CheckboxSelectMultiple.

comment:11 by GitHub <noreply@…>, 8 years ago

In 87c5e7e:

Refs #27186 -- Fixed model form default fallback for CheckboxSelectMultiple.

comment:12 by Tim Graham <timograham@…>, 8 years ago

In f23c03e:

[1.10.x] Refs #27186 -- Fixed model form default fallback for CheckboxSelectMultiple.

Backport of 87c5e7efebd040aef0f0479ccf86877155bb5cea from master

comment:13 by Tim Graham, 8 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top