#24339: Exception at /add admin view when using DurationField
---------------------------------+-----------------------
     Reporter:  yoyoma           |      Owner:  nobody
         Type:  Uncategorized    |     Status:  new
    Component:  Uncategorized    |    Version:  1.8alpha1
     Severity:  Release blocker  |   Keywords:
 Triage Stage:  Unreviewed       |  Has patch:  0
Easy pickings:  1                |      UI/UX:  0
---------------------------------+-----------------------
 == Setup ==

 Make an app with a model that has a `DurationField`. (started fresh app to
 verify)

 == Exception ==

 {{{AttributeError: 'NoneType' object has no attribute 'days'}}} was the
 error message.

 == Cause ==

 
https://github.com/django/django/blob/0ed7d155635da9f79d4dd67e4889087d3673c6da/django/forms/fields.py#L517
 (assumes {{{value}}} is a {{{timedelta}}})

 == Solution ==

 {{{
     def prepare_value(self, value):
         if isinstance(value, datetime.timedelta):
             return duration_string(value)
         return value
 }}}

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.e3222a1b973f9a2b4ebe384b326a7c8c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to