#23405: Blank-able CharFields require default=''
----------------------------+------------------------------------
     Reporter:  yuvadm      |                    Owner:  coldmind
         Type:  Bug         |                   Status:  assigned
    Component:  Migrations  |                  Version:  1.7
     Severity:  Normal      |               Resolution:
     Keywords:              |             Triage Stage:  Accepted
    Has patch:  1           |      Needs documentation:  0
  Needs tests:  0           |  Patch needs improvement:  0
Easy pickings:  0           |                    UI/UX:  0
----------------------------+------------------------------------

Comment (by coldmind):

 {{{
 <truecoldmind> MarkusH, this behavior is in conflict in South behavior and
 can be annoying. What if I need to add few dozens of textfields, I will be
 forced to type empty string for each of this field
 <MarkusH> Django's migrations don't behave like south in many ways.
 <MarkusH> be explicit and define a default on the field in the model
 <MarkusH> I don't think this should be handled by the migration framework.
 <mYk> MarkusH: did you see comment 5 L
 <mYk> s/L/?/
 <truecoldmind> MarkusH, for now I'm also doubt if it check should be in
 autodetector. But, it is the known fact that default value for textfield
 and charfield is empty string, and I think it should be used if user
 didn't specified other default value. But where this check should be
 placed?
 <MarkusH> mYk: yes
 <MarkusH> mYk: What if I have a custom field that inherits from neither
 Char nor TextField but has the same internal type as CharField?
 <truecoldmind> I asked you a question in a pullrequest - can we check for
 internal type instead of class instance check?
 <MarkusH> Checking for internal type shoudn't be done outside of backends,
 imo
 <truecoldmind> MarkusH, Seems reasonable. But what check in autodetecor
 should be placed? We will need one
 <MarkusH> gimme a sec. trying something out
 <MarkusH> truecoldmind: https://dpaste.de/GmrV
 <MarkusH> https://dpaste.de/4i0j
 <MarkusH> maybe even skip the "self.blank"
 <MarkusH> but I think that's a better way to go
 <MarkusH> You'd need to figure out though what the implications of that
 are
 <MarkusH> changes to internal Django migrations
 <truecoldmind> MarkusH, looks good, but what about autodetector?
 <MarkusH> no change required
 <truecoldmind> MarkusH, `field.has_default()`, of course.
 <truecoldmind> What do you mean with " implications " ?
 <MarkusH> yah
 <MarkusH> What happens to projects that upgrade? Does this generate a new
 migration file?
 <MarkusH> Are there situations that might break?
 <truecoldmind> MarkusH, thank you, I'll do some research. I will post that
 chat log as comment to pull request.
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23405#comment:13>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.c7635b0b4abc30d99a5cd9e6d6ac22be%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to