#213 closed defect (fixed)
error submitting empty times
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | contrib.admin | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
If I try to submit a datetime field in the admin interface, and the time is not provided (I'm setting disabled=true on the field with javascript), I get the following traceback:
Traceback (most recent call last): File "/usr/local/lib/python2.4/site-packages/django/core/handlers/base.py", line 63, in get_response return callback(request, **param_dict) File "/usr/local/lib/python2.4/site-packages/django/views/admin/main.py", line 767, in add_stage manipulator.do_html2python(new_data) File "/opt/local/lib/python2.4/site-packages/django/core/formfields.py", line 98, in do_html2python new_data.setlist(field.field_name, [field.__class__.html2python(None)]) File "/opt/local/lib/python2.4/site-packages/django/core/formfields.py", line 654, in html2python time_tuple = time.strptime(data, '%H:%M:%S') File "/usr/local/lib/python2.4/_strptime.py", line 290, in strptime found = format_regex.match(data_string) TypeError: expected string or buffer
Here's a diff against 331 that fixes the problem. (I don't know if this is a use-case you want to deal with, but the fix seems pretty trivial.)
Index: django/core/formfields.py =================================================================== --- django/core/formfields.py (revision 331) +++ django/core/formfields.py (working copy) @@ -649,6 +649,8 @@ def html2python(data): "Converts the field into a datetime.time object" import time, datetime + if data is None: + return None try: try: time_tuple = time.strptime(data, '%H:%M:%S')
Change History (2)
comment:1 by , 19 years ago
Description: | modified (diff) |
---|
comment:2 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
(In [702]) Fixed #213 -- Improved formfields.TimeField.html2python() so that it doesn't fail for None input