[Django] #24445: DurationField with default='1 00:00' triggers validation on otherwise empty inline formsets

3 views
Skip to first unread message

Django

unread,
Mar 3, 2015, 5:26:49 PM3/3/15
to django-...@googlegroups.com
#24445: DurationField with default='1 00:00' triggers validation on otherwise empty
inline formsets
-------------------------------+--------------------
Reporter: yoyoma | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
When I reported #24391 I should have had the sense to check
{{{DurationField}}}, but I didn't. Note, this isn't caused by a callable
{{{default}}} argument, rather a string.

My initial thought is that this has something to do with the conversion
process of a given string value into a {{{timedelta}}}, etc., but I
haven't had a chance to really dig in, yet. I just barely finished work
and I have to run a bunch of errands, or I'd dive straight into the code.
However, I wanted to at least get the bug report in here right away.

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

Django

unread,
Mar 3, 2015, 5:27:21 PM3/3/15
to django-...@googlegroups.com
#24445: DurationField with default='1 00:00' triggers validation on otherwise empty
inline formsets
------------------------+--------------------------------------
Reporter: yoyoma | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: master
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 yoyoma):

* needs_better_patch: => 0
* component: Uncategorized => Forms
* needs_tests: => 0
* version: 1.7 => master
* needs_docs: => 0
* type: Uncategorized => Bug


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

Django

unread,
Mar 4, 2015, 5:46:17 PM3/4/15
to django-...@googlegroups.com
#24445: DurationField with default='1 00:00' triggers validation on otherwise empty
inline formsets
---------------------------------+--------------------------------------
Reporter: yoyoma | Owner: nobody

Type: Bug | Status: new
Component: Forms | Version: master
Severity: Release blocker | 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 yoyoma):

* severity: Normal => Release blocker


Comment:

I've set the severity to release blocker, since this is essentially the
same regression (thought via different means) as #24391. I've looked
through the code a bit and can't find anything obvious that could be
causing this issue. I'm going to look some more tomorrow night.

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

Django

unread,
Mar 5, 2015, 3:31:23 AM3/5/15
to django-...@googlegroups.com
#24445: DurationField with default='1 00:00' triggers validation on otherwise empty
inline formsets
------------------------+--------------------------------------
Reporter: yoyoma | Owner: nobody

Type: Bug | Status: new
Component: Forms | Version: master
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 claudep):

* severity: Release blocker => Normal


Comment:

In fact, you'll find the exact same behavior with current date-based
fields. If you provide an initial or default value, you should provide a
date/datetime Python value, not a string representation. By analogy, you
should provide a `timedelta` value for your `DurationField` default value.

We *could* change that, other opinions welcome.

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

Django

unread,
Mar 5, 2015, 6:04:25 AM3/5/15
to django-...@googlegroups.com
#24445: DurationField with default='1 00:00' triggers validation on otherwise empty
inline formsets
------------------------+--------------------------------------
Reporter: yoyoma | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: wontfix
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 timgraham):

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


Comment:

I don't see a need to complicate things by allowing differing types for
defaults. Maybe there's an opportunity to use the checks framework to
validate defaults are the proper type, but I'll leave that for a new
ticket if someone wants to try implementing it.

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

Django

unread,
Mar 5, 2015, 6:04:36 AM3/5/15
to django-...@googlegroups.com
#24445: DurationField with default='1 00:00' triggers validation on otherwise empty
inline formsets
------------------------+--------------------------------------
Reporter: yoyoma | Owner: nobody

Type: Bug | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: invalid
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 timgraham):

* resolution: wontfix => invalid


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

Django

unread,
Mar 5, 2015, 9:53:15 AM3/5/15
to django-...@googlegroups.com
#24445: DurationField with default='1 00:00' triggers validation on otherwise empty
inline formsets
------------------------+--------------------------------------
Reporter: yoyoma | Owner: nobody

Type: Bug | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed

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

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

Comment (by yoyoma):

@claudep @timgraham {{{timedelta}}} is obviously the right thing to use
here, and I'm not sure what in the world I was thinking when I used a
string. I think it was because I was getting so used to typing the string
value into the admin, and just totally spaced it. I'm sorry for wasting a
ticket and your time before simply taking 30 seconds to RTFM @
https://docs.djangoproject.com/en/1.8/ref/models/fields/#durationfield

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

Reply all
Reply to author
Forward
0 new messages