Code

Opened 6 years ago

Closed 6 years ago

#6754 closed (wontfix)

Unclear documentation of default date/time fields values

Reported by: kip_parker Owned by: nobody
Component: Documentation Version: master
Severity: Keywords: models, DateTimeField, DateField, TimeField
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

It wasn't clear from the documentation that date/time fieldstake a python date object as a default. I assumed that:

start = models.TimeField(default='20:00')

would be OK, but I needed

import datetime
start = models.TimeField(default=datetime.datetime(2008, 1, 31, 20, 00, 00)

Attachments (0)

Change History (1)

comment:1 Changed 6 years ago by jacob

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

I'm not sure why you'd expect this to work -- would you also expect IntegerField(default="10") to work, too? There's nothing in the documentation that says that Django will let you be sloppy about types in this way, so I don't see how we could be clearer.

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.