Django

Code

Ticket #4428 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

DateTimeField's clean() does not support millisecond resolution

Reported by: berto Assigned to: mtredinnick
Milestone: Component: Forms
Version: SVN Keywords: datetimefield, datetimeinput
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 1

Description

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.

Attachments

datetimefield_millisecond.patch (2.3 kB) - added by berto on 05/30/07 00:42:25.
fields.diff (428 bytes) - added by andrews on 09/14/07 01:03:50.
widgets.diff (1.0 kB) - added by andrews on 09/14/07 01:04:09.
new_datetimefield_millisecond.diff (3.9 kB) - added by Wiliam Alves de Souza(waa) on 09/17/07 12:39:40.
Code improvements and tests

Change History

05/30/07 00:42:25 changed by berto

  • attachment datetimefield_millisecond.patch added.

09/13/07 17:42:34 changed by SmileyChris

  • needs_better_patch set to 1.
  • stage changed from Unreviewed to Accepted.
  • component changed from Uncategorized to django.newforms.
  • needs_tests changed.
  • needs_docs changed.

09/13/07 23:56:03 changed by andrews

  • keywords set to datetimefield, datetimeinput.
  • owner changed from nobody to andrews.

09/14/07 01:03:50 changed by andrews

  • attachment fields.diff added.

09/14/07 01:04:09 changed by andrews

  • attachment widgets.diff added.

09/14/07 01:07:10 changed by andrews

  • status changed from new to closed.
  • resolution set to fixed.

I create a DateTimeInput? to fix this problem. The default format is settiings.DATETIME_FORMAT. For to configure format use parameter format.

09/14/07 01:13:07 changed by russellm

  • status changed from closed to reopened.
  • resolution deleted.

Ticket isn't fixed until it's in the tree.

09/16/07 07:45:06 changed by PhiR

  • status changed from reopened to closed.
  • resolution set to duplicate.

see #4487.

09/16/07 07:46:33 changed by mtredinnick

  • status changed from closed to reopened.
  • resolution deleted.

Not fixing quite the same problem as #4487, since SplitDateTime widget isn't the default for DateTime field display).

09/16/07 07:46:48 changed by mtredinnick

  • owner changed from andrews to mtredinnick.
  • status changed from reopened to new.

09/17/07 12:39:40 changed by Wiliam Alves de Souza(waa)

  • attachment new_datetimefield_millisecond.diff added.

Code improvements and tests

10/21/07 09:50:47 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [6578]) Changed the default form presentation of datetime values to not include the fractional second values (they usually aren't going to be needed). Based on patches from yi.codeplayer@gmail.com, andrews and Wiliam Alves de Souza. Fixed #4428, #4487


Add/Change #4428 (DateTimeField's clean() does not support millisecond resolution)




Change Properties
Action