[Django] #27186: Cannot change DateTimeField with default via Admin since Django 1.10.1

20 views
Skip to first unread message

Django

unread,
Sep 6, 2016, 8:43:32 AM9/6/16
to django-...@googlegroups.com
#27186: Cannot change DateTimeField with default via Admin since Django 1.10.1
-------------------------------+--------------------
Reporter: michael-k | Owner: nobody
Type: Uncategorized | Status: new
Component: Forms | Version: 1.10
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
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 [https://github.com/michael-k/datetimefieldbroken
example project] to easily reproduce the problem.

It has a
[https://github.com/michael-k/datetimefieldbroken/blob/b6ff942dd328007bf4af199b91d20d6cbfbb09d5/datetimefieldbroken/main/models.py#L5-L7
model ''Dummy''] with two DateTimeFields. One ''with'' and one
''without'' a default (''django.utils.timezone.now''). The
[https://github.com/michael-k/datetimefieldbroken/blob/b6ff942dd328007bf4af199b91d20d6cbfbb09d5/datetimefieldbroken/main/admin.py#L6-L8
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 [https://github.com/django/django/pull/7195/files PR 7195]
(redaring [https://code.djangoproject.com/ticket/27039 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.

--
Ticket URL: <https://code.djangoproject.com/ticket/27186>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 6, 2016, 8:51:19 AM9/6/16
to django-...@googlegroups.com
#27186: Cannot change DateTimeField with default via Admin since Django 1.10.1
-------------------------------+--------------------------------------

Reporter: michael-k | Owner: nobody
Type: Uncategorized | Status: new
Component: Forms | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by michael-k):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Old description:

New description:

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 [https://github.com/michael-k/datetimefieldbroken
example project] to easily reproduce the problem.

It has a
[https://github.com/michael-k/datetimefieldbroken/blob/b6ff942dd328007bf4af199b91d20d6cbfbb09d5/datetimefieldbroken/main/models.py#L5-L7
model ''Dummy''] with two DateTimeFields. One ''with'' and one
''without'' a default (''django.utils.timezone.now''). The
[https://github.com/michael-k/datetimefieldbroken/blob/b6ff942dd328007bf4af199b91d20d6cbfbb09d5/datetimefieldbroken/main/admin.py#L6-L8
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 [https://github.com/django/django/pull/7068 PR 7068]
(regarding [https://code.djangoproject.com/ticket/27039 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.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/27186#comment:1>

Django

unread,
Sep 6, 2016, 8:51:58 AM9/6/16
to django-...@googlegroups.com
#27186: Cannot change DateTimeField with default via Admin since Django 1.10.1
-------------------------------+--------------------------------------

Reporter: michael-k | Owner: nobody
Type: Uncategorized | Status: new
Component: Forms | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Description changed by michael-k:

Old description:

> 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 [https://github.com/michael-k/datetimefieldbroken
> example project] to easily reproduce the problem.
>
> It has a
> [https://github.com/michael-k/datetimefieldbroken/blob/b6ff942dd328007bf4af199b91d20d6cbfbb09d5/datetimefieldbroken/main/models.py#L5-L7
> model ''Dummy''] with two DateTimeFields. One ''with'' and one
> ''without'' a default (''django.utils.timezone.now''). The
> [https://github.com/michael-k/datetimefieldbroken/blob/b6ff942dd328007bf4af199b91d20d6cbfbb09d5/datetimefieldbroken/main/admin.py#L6-L8
> 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 [https://github.com/django/django/pull/7068 PR 7068]
> (regarding [https://code.djangoproject.com/ticket/27039 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.

New description:

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 [https://github.com/michael-k/datetimefieldbroken
example project] to easily reproduce the problem.

It has a
[https://github.com/michael-k/datetimefieldbroken/blob/b6ff942dd328007bf4af199b91d20d6cbfbb09d5/datetimefieldbroken/main/models.py#L5-L7
model ''Dummy''] with two DateTimeFields. One ''with'' and one
''without'' a default (''django.utils.timezone.now''). The
[https://github.com/michael-k/datetimefieldbroken/blob/b6ff942dd328007bf4af199b91d20d6cbfbb09d5/datetimefieldbroken/main/admin.py#L6-L8
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 [https://github.com/django/django/pull/7068 PR 7068]
(regarding [https://code.djangoproject.com/ticket/27039 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.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/27186#comment:2>

Django

unread,
Sep 6, 2016, 9:12:25 AM9/6/16
to django-...@googlegroups.com
#27186: Cannot change DateTimeField with default via Admin since Django 1.10.1
---------------------------------+------------------------------------
Reporter: michael-k | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.10
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by timgraham):

* type: Uncategorized => Bug
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/27186#comment:3>

Django

unread,
Sep 6, 2016, 5:13:31 PM9/6/16
to django-...@googlegroups.com
#27186: Cannot change DateTimeField with default via Admin since Django 1.10.1
---------------------------------+-------------------------------------
Reporter: michael-k | Owner: timgraham
Type: Bug | Status: assigned
Component: Forms | Version: 1.10

Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+-------------------------------------
Changes (by timgraham):

* owner: nobody => timgraham
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/27186#comment:4>

Django

unread,
Sep 7, 2016, 10:32:45 AM9/7/16
to django-...@googlegroups.com
#27186: Cannot change DateTimeField with default via Admin since Django 1.10.1
---------------------------------+-------------------------------------
Reporter: michael-k | Owner: timgraham
Type: Bug | Status: assigned
Component: Forms | Version: 1.10

Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+-------------------------------------
Changes (by timgraham):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/7217 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/27186#comment:5>

Django

unread,
Sep 13, 2016, 4:02:18 PM9/13/16
to django-...@googlegroups.com
#27186: Cannot change FileInput, MultiWidget, SplitDateTimeWidget, and
SelectDateWidget with model field default since Django 1.10.1

---------------------------------+-------------------------------------
Reporter: michael-k | Owner: timgraham
Type: Bug | Status: assigned
Component: Forms | Version: 1.10

Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+-------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/27186#comment:6>

Django

unread,
Sep 22, 2016, 1:05:53 PM9/22/16
to django-...@googlegroups.com
#27186: Cannot change FileInput, MultiWidget, SplitDateTimeWidget, and
SelectDateWidget with model field default since Django 1.10.1
---------------------------------+--------------------------------------
Reporter: Michael Käufl | Owner: Tim Graham
Type: Bug | Status: closed
Component: Forms | Version: 1.10
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"3507d4e773aa9ff2336e7230ba231c4ba6eb568f" 3507d4e7]:
{{{
#!CommitTicketReference repository=""
revision="3507d4e773aa9ff2336e7230ba231c4ba6eb568f"
Fixed #27186 -- Fixed model form default fallback for MultiWidget,
FileInput, SplitDateTimeWidget, SelectDateWidget, and SplitArrayWidget.

Thanks Matt Westcott for the review.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27186#comment:7>

Django

unread,
Sep 22, 2016, 2:00:32 PM9/22/16
to django-...@googlegroups.com
#27186: Cannot change FileInput, MultiWidget, SplitDateTimeWidget, and
SelectDateWidget with model field default since Django 1.10.1
---------------------------------+--------------------------------------
Reporter: Michael Käufl | Owner: Tim Graham
Type: Bug | Status: closed
Component: Forms | Version: 1.10

Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"0b59ea3343ef6f035064cfae1608f54c5a3fd147" 0b59ea33]:
{{{
#!CommitTicketReference repository=""
revision="0b59ea3343ef6f035064cfae1608f54c5a3fd147"
[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
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27186#comment:8>

Django

unread,
Sep 29, 2016, 11:34:01 AM9/29/16
to django-...@googlegroups.com
#27186: Cannot change CheckboxSelectMultiple, FileInput, MultiWidget,

SplitDateTimeWidget, and SelectDateWidget with model field default since
Django 1.10.1
---------------------------------+--------------------------------------
Reporter: Michael Käufl | Owner: Tim Graham
Type: Bug | Status: new
Component: Forms | Version: 1.10
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Tim Graham):

* status: closed => new
* has_patch: 1 => 0
* resolution: fixed =>


Comment:

As reported in #27291, `CheckboxSelectMultiple` is also affected.

--
Ticket URL: <https://code.djangoproject.com/ticket/27186#comment:9>

Django

unread,
Sep 29, 2016, 12:13:24 PM9/29/16
to django-...@googlegroups.com
#27186: Cannot change CheckboxSelectMultiple, FileInput, MultiWidget,
SplitDateTimeWidget, and SelectDateWidget with model field default since
Django 1.10.1
---------------------------------+--------------------------------------
Reporter: Michael Käufl | Owner: Tim Graham
Type: Bug | Status: new
Component: Forms | Version: 1.10

Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Tim Graham):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/7318 PR] for
`CheckboxSelectMultiple`.

--
Ticket URL: <https://code.djangoproject.com/ticket/27186#comment:10>

Django

unread,
Sep 30, 2016, 2:49:58 PM9/30/16
to django-...@googlegroups.com
#27186: Cannot change CheckboxSelectMultiple, FileInput, MultiWidget,
SplitDateTimeWidget, and SelectDateWidget with model field default since
Django 1.10.1
---------------------------------+--------------------------------------
Reporter: Michael Käufl | Owner: Tim Graham
Type: Bug | Status: new
Component: Forms | Version: 1.10

Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by GitHub <noreply@…>):

In [changeset:"87c5e7efebd040aef0f0479ccf86877155bb5cea" 87c5e7e]:
{{{
#!CommitTicketReference repository=""
revision="87c5e7efebd040aef0f0479ccf86877155bb5cea"
Refs #27186 -- Fixed model form default fallback for
CheckboxSelectMultiple.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27186#comment:11>

Django

unread,
Sep 30, 2016, 2:57:29 PM9/30/16
to django-...@googlegroups.com
#27186: Cannot change CheckboxSelectMultiple, FileInput, MultiWidget,
SplitDateTimeWidget, and SelectDateWidget with model field default since
Django 1.10.1
---------------------------------+--------------------------------------
Reporter: Michael Käufl | Owner: Tim Graham
Type: Bug | Status: new
Component: Forms | Version: 1.10

Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"f23c03ebc81c64b8b41f3aae0dbe93fc283cc43d" f23c03e]:
{{{
#!CommitTicketReference repository=""
revision="f23c03ebc81c64b8b41f3aae0dbe93fc283cc43d"
[1.10.x] Refs #27186 -- Fixed model form default fallback for
CheckboxSelectMultiple.

Backport of 87c5e7efebd040aef0f0479ccf86877155bb5cea from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27186#comment:12>

Django

unread,
Sep 30, 2016, 2:57:44 PM9/30/16
to django-...@googlegroups.com
#27186: Cannot change CheckboxSelectMultiple, FileInput, MultiWidget,
SplitDateTimeWidget, and SelectDateWidget with model field default since
Django 1.10.1
---------------------------------+--------------------------------------
Reporter: Michael Käufl | Owner: Tim Graham
Type: Bug | Status: closed
Component: Forms | Version: 1.10
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => fixed


--
Ticket URL: <https://code.djangoproject.com/ticket/27186#comment:13>

Reply all
Reply to author
Forward
0 new messages