Opened 18 years ago
Closed 18 years ago
#4630 closed (fixed)
SplitDateTimeField - TypeError when required=False and data not entered
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Forms | Version: | newforms-admin |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When datetime db field (in model) is blank=True, null=True, then I get TypeError when submit(save) form for this model with no date and/or time filled in:
TypeError at /admin/cms/article/239/ combine() argument 1 must be datetime.date, not None Request Method: POST Request URL: http://127.0.0.1:8000/admin/cms/article/239/ Exception Type: TypeError Exception Value: combine() argument 1 must be datetime.date, not None Exception Location: /usr/lib/python2.4/site-packages/django/newforms/fields.py in compress, line 561 Python Executable: /usr/bin/python Python Version: 2.4.3
Here are last few lines of traceback:
File "/usr/lib/python2.4/site-packages/django/newforms/forms.py" in _get_errors 93. self.full_clean() File "/usr/lib/python2.4/site-packages/django/newforms/forms.py" in full_clean 206. value = field.clean(value) File "/usr/lib/python2.4/site-packages/django/newforms/fields.py" in clean 541. return self.compress(clean_data) File "/usr/lib/python2.4/site-packages/django/newforms/fields.py" in compress 561. return datetime.datetime.combine(*data_list)
Attachments (2)
Change History (5)
comment:1 by , 18 years ago
by , 18 years ago
Attachment: | possible_patch_fields.py.diff added |
---|
by , 18 years ago
Attachment: | splitdatetimefield.patch added |
---|
comment:2 by , 18 years ago
Component: | Admin interface → django.newforms |
---|---|
Has patch: | set |
Summary: | [newforms-admin] SplitDateTimeField - !TypeError when datetime is blank=True,null=True → SplitDateTimeField - TypeError when required=False and data not entered |
Triage Stage: | Unreviewed → Ready for checkin |
This is a more complete fix for the bug. Compress should still do some logic if it requires all the fields to be there if it required=False
.
Tests included.
comment:3 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
I'm not sure, that I know how to fix this bug correctly. I think the bug is on line 521 in fields.py:
IHMO value is always list of values from fields, so "not value" is not a proper condition. I created patch which checks all values in list "value" (look at patch). Is that correct fix for this bug?