Opened 10 years ago
Closed 10 years ago
#22856 closed Bug (invalid)
Blank=False not being enforced
Reported by: | fongandrew2 | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | 1.7-beta-2 |
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
It is possible to save a blank value to CharField(blank=False) without Django raising any exception.
from django.db import models # Create your models here. class MyModel(models.Model): my_charfield = models.CharField(max_length=32, blank=False) # This should fail, but it does not MyModel().save()
Attachments (1)
Change History (2)
by , 10 years ago
Attachment: | testproj.zip added |
---|
comment:1 by , 10 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Thanks for the report, but this is working as designed. The blank
parameter is only for validation, and validation is not done automatically by save(). The reason for the latter is that in the general case it can't be assumed that the caller of save()
is in a position to catch and handle validation errors. If you want your model data validated before saving, you should call full_clean()
.
Simple testcase reproducing issue