Code

Opened 8 years ago

Closed 8 years ago

#2513 closed defect (wontfix)

LazyDate better return date than datetime

Reported by: wangbin@… Owned by: adrian
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: UI/UX:

Description

We have model has a DateField called expire_date which set default to LazyDate(days=60), it works well in firefox, but under safari and IE it shows error when we save that object, because LazyDate.get_value method return datetime object, wich make the validation fails, I think it is better to return date object, which will be useful both to DateField and DateTimeField.

Attachments (2)

lazydate.patch (500 bytes) - added by wangbin@… 8 years ago.
patch for django 0.95
lazydate.2.patch (452 bytes) - added by wangbin@… 8 years ago.
patch for django 0.91

Download all attachments as: .zip

Change History (6)

Changed 8 years ago by wangbin@…

patch for django 0.95

Changed 8 years ago by wangbin@…

patch for django 0.91

comment:1 Changed 8 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

(In [3566]) Fixed #2513 -- Changed LazyDate.get_value() to return date objects, not datetime objects

comment:2 Changed 8 years ago by Alex Dedul

  • Resolution fixed deleted
  • Status changed from closed to reopened

Hm, for DateTimeField with default it sets time to 00:00 requiring users to manually set time everytime. Maybe add another class LazyDateTime ?

comment:3 Changed 8 years ago by Alex Dedul

Or even better revert LazyDate and fix the validation where needed ?

comment:4 Changed 8 years ago by adrian

  • Resolution set to wontfix
  • Status changed from reopened to closed

LazyDate is eventually going away, in favor of callable arguments, so I'm marking this as wontfix.

Old:

default=LazyDate().

New:

default=datetime.date.today

Old:

default=LazyDate(days=1)

New:

default=lambda: datetime.date.today() + datetime.timedelta(days=1)

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.