Opened 20 years ago
Closed 20 years ago
#1043 closed defect (invalid)
DateField doesn't work with blank=True
| Reported by: | 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 , 20 years ago
comment:2 by , 20 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
Yeah, you need null=True on that DateField.
You need to add
null=Trueas well asblank=True. I wonder if this should be done automatically whenblank=Trueis specified, since that is what is wanted in 90% of cases?