#35671: Document how to disallow blank values in Char/TextFields
-------------------------------------+-------------------------------------
     Reporter:  Clifford Gama        |                    Owner:  (none)
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  5.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  Field.null;          |             Triage Stage:  Accepted
  IntegrityError;                    |
  NotNullConstraint; Field.default   |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

 * stage:  Unreviewed => Accepted
 * summary:
     Field.null=False on string-based fields behaves inconsistently with
     the typical usage of Field.null.
     => Document how to disallow blank values in Char/TextFields
 * type:  Bug => Cleanup/optimization

Comment:

 I don't think we can change the behavior here as this would be a breaking
 change and I think it makes sense that given a field which cannot be null,
 but can be a blank string, without a default set, it defaults to a blank
 string

 But I agree that this is not clear in the docs and we can make an update
 there

 Note, this is about how given a model:
 {{{
 class StringModel(Model):
     field = models.CharField(blank=False, null=False)
 }}}
 the value for `StringModel().field` is `""`, which is determined by the
 property `Field._get_default`
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35671#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701914ad5fb38-2306fed4-b7a8-4fd5-baa5-7d4d36e63c46-000000%40eu-central-1.amazonses.com.

Reply via email to