Opened 11 years ago

Closed 11 years ago

#22160 closed Bug (needsinfo)

TimeField default argument not working.

Reported by: vlad.dragos.002@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.6
Severity: Normal 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

Hello,

The problem is that i have the field definition like this:
pickup_time_from = models.TimeField(default=datetime.time(hour=9))

And when I try to validate the model through a ModelForm it give me the error that the field is required.
I also tried the following:
pickup_time_from = models.TimeField(default=datetime.time(hour=9), blank=True)
But it throws the following exception:
null value in column "pickup_time_from" violates not-null constraint

Hope this helps,
Best regards,
Vlad

Change History (2)

comment:1 by Claude Paroz, 11 years ago

Is this related to #15725?

comment:2 by Aymeric Augustin, 11 years ago

Resolution: needsinfo
Status: newclosed

Aren't you confusing default and initial too?

Note: See TracTickets for help on using tickets.
Back to Top