Opened 17 years ago
Closed 17 years ago
#7970 closed (invalid)
DateField incorrect default value in newforms admin
| Reported by: | David Cramer | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.admin | Version: | dev |
| Severity: | 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
The DateField is starting with an incorrect value when using default=datetime.datetime.now in the admin.
Note:
See TracTickets
for help on using tickets.
When you provide a callable for the default, the result of calling that function/method/object is used as the default value. It's up to you to provide a callable that returns a value of the right type. In this case,
datetime.date.todaywould be an appropriate callable for a DateField. Usingdatetime.datetime.nowreturns a date and time, which isn't appropriate for that type of field.