#32799: Inconsistency regarding the default value of CharField
-------------------------------+--------------------------------------
     Reporter:  Adam Sołtysik  |                    Owner:  nobody
         Type:  New feature    |                   Status:  closed
    Component:  Migrations     |                  Version:  3.2
     Severity:  Normal         |               Resolution:  wontfix
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------

Comment (by Adam Sołtysik):

 > IMO these are two different scenarios.

 The point is to make these two different scenarios work consistently, not
 to break the principle of least astonishment. When model objects behave
 like they have a valid default value, it's surprising that migrations
 behave like there's no valid default.

 > For a string-based field with null=False you have one possible values
 for "no data" i.e. the empty string that's why Django uses it when value
 is not provided for a non-nullable string-based field.

 The same could apply to migrations. Since there's only one possible value
 for "no data" for the existing rows, it's probably better to use that than
 to ask for that value or crash.

 > Migrations asks for a default value for existing rows when adding a non-
 nullable field to the model, and does it consistently for all type of
 fields.

 Except for the fact that currently `blank=True` can be used with char
 fields instead of a default value for the migration to work properly, even
 though `blank` parameter is said
 [https://docs.djangoproject.com/en/3.2/ref/models/fields/#blank in the
 documentation] to matter for form validation only.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32799#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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.592b35f86dbcd38f3bd9339b571edea9%40djangoproject.com.

Reply via email to