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.
* 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>
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>
* type: Uncategorized => Bug
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/27186#comment:3>
* owner: nobody => timgraham
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/27186#comment:4>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/7217 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/27186#comment:5>
--
Ticket URL: <https://code.djangoproject.com/ticket/27186#comment:6>
* 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>
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>
* 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>
* 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>
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>
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>
* status: new => closed
* resolution: => fixed
--
Ticket URL: <https://code.djangoproject.com/ticket/27186#comment:13>