Opened 8 years ago

Last modified 8 years ago

#27186 closed Bug

Cannot change DateTimeField with default via Admin since Django 1.10.1 — at Version 1

Reported by: Michael Käufl Owned by: nobody
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 belive 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 (1)

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

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top