DateTimeField's clean() does not support millisecond resolution
I ran into this problem when experimenting with newforms' form_from_instance(). When a model with a DateTimeField is saved and then retrieved using form_for_instance, the value contains milliseconds. The DateTimeField's clean() does not handle the milliseconds and validation fails. I found this snippet and incorporated it into clean():
http://www.thescripts.com/forum/thread506538.html
Attached is a patch.
Thanks!
-berto.
Change History
(12)
Component: |
Uncategorized → django.newforms
|
Patch needs improvement: |
set
|
Triage Stage: |
Unreviewed → Accepted
|
Keywords: |
datetimefield datetimeinput added
|
Owner: |
changed from nobody to Andrews Medina
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
Resolution: |
fixed
|
Status: |
closed → reopened
|
Resolution: |
→ duplicate
|
Status: |
reopened → closed
|
Resolution: |
duplicate
|
Status: |
closed → reopened
|
Owner: |
changed from Andrews Medina to Malcolm Tredinnick
|
Status: |
reopened → new
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
I create a DateTimeInput to fix this problem. The default format is settiings.DATETIME_FORMAT.
For to configure format use parameter format.