Opened 9 years ago

Closed 9 years ago

#4351 closed (fixed)

Blank char/text fields

Reported by: anonymous Owned by: jacob
Component: Documentation Version: master
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: UI/UX:


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)

4351.patch (651 bytes) - added by SmileyChris 9 years ago.
Documentation clarification

Download all attachments as: .zip

Change History (3)

Changed 9 years ago by SmileyChris

Documentation clarification

comment:1 Changed 9 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to 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 Changed 9 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(In [5351]) Fixed #4351 -- Attempted to make it easier for readers to see the difference
between null and blank if they are reading from top to bottom.

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