Opened 17 years ago
Closed 17 years ago
#4351 closed (fixed)
Blank char/text fields
Reported by: | anonymous | Owned by: | Jacob |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Keywords: | blank, null | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The documentation does a good job of pointing out that blank should be used for text/char fields instead of null. What wasn't totally clear is that for non-character based fields (e.g. Integer) you have to use blank=True for the validator to allow the field to be empty (e.g. when creating a new instance in Admin). Also, I would assume in this situation it substitutes NULL instead of an empty string, making it different from the char/text field case. Figured it'd be worth a mention.
The particular portion of the documentation can be found here:
"Note that empty string values will always get stored as empty strings, not as NULL — so use null=True for non-string fields such as integers, booleans and dates.
Avoid using null on string-based fields such as CharField and TextField unless you have an excellent reason. If a string-based field has null=True, that means it has two possible values for “no data”: NULL, and the empty string. In most cases, it’s redundant to have two possible values for “no data;” Django convention is to use the empty string, not NULL."
Attachments (1)
Change History (3)
by , 17 years ago
Attachment: | 4351.patch added |
---|
comment:1 by , 17 years ago
Triage Stage: | Unreviewed → Ready for checkin |
---|
This is an FAQ, even with the current documentation in blank
. Can't hurt to clarify it in null
too.
comment:2 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Documentation clarification