#27697: JSONField with blank=True is rendered as non-required field in a 
ModelForm
-------------------------------------+-------------------------------------
     Reporter:  aruseni              |                    Owner:  Andrew
                                     |  Nester
         Type:  Bug                  |                   Status:  assigned
    Component:  contrib.postgres     |                  Version:  1.10
     Severity:  Normal               |               Resolution:
     Keywords:  postgres             |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

 * needs_better_patch:  0 => 1


Comment:

 I think what I would expect (and I'm certain open to other opinions,
 including your own if you disagree) with `blank=True` is that nothing is
 rendered in the widget and if nothing is submitted, that empty string is
 transformed into an empty dict so it can be saved. In particular, I'm
 thinking of an API context where the `initial={}` that your proposed isn't
 going to have an effect since the API is only submitted values and doesn't
 receive an initial form.

 I wish we could solve the null case without adding a new form option
 ("invalidate_null" as you proposed). If "null" is submitted though, an
 error message might indeed be more appropriate than transforming that into
 an empty dict. If we need to add some new form option, perhaps
 `allow_null=True` (default) would be more consistent with other existing
 options such as `allow_unicode`.

--
Ticket URL: <https://code.djangoproject.com/ticket/27697#comment:10>
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/065.c94bee148a1a1d2f03030987cc3d970d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to