Opened 19 years ago

Closed 19 years ago

#1043 closed defect (invalid)

DateField doesn't work with blank=True

Reported by: wojtek@… Owned by: Adrian Holovaty
Component: Core (Other) Version:
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

I created the following model:
class Event(meta.Model):

heading = meta.CharField(maxlength=256)
description = meta.TextField()
added = meta.DateField(auto_now_add = True)
remind = meta.DateField(blank = True)
file = meta.FileField(upload_to = MEDIA_ROOT, blank = True)

If I don't fill out the 'remind' field in the form - I get the following error:
ERROR: null value in column "remind" violates not-null constraint INSERT INTO "crm_events" ("heading","description","added","remind","file") VALUES ('foo','bar','2005-12-12',NULL,)

So apparently that column should be set to NOT null automagically.

Change History (2)

comment:1 by Esaj, 19 years ago

You need to add null=True as well as blank=True. I wonder if this should be done automatically when blank=True is specified, since that is what is wanted in 90% of cases?

comment:2 by Adrian Holovaty, 19 years ago

Resolution: invalid
Status: newclosed

Yeah, you need null=True on that DateField.

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