1. Create a `Model` and add the following field:
`foo = models.TextField(blank=True, null=True)`
2. Create a corresponding `ModelForm`
3. Create a template to render the form
4. Load the template in a browser, leave `foo` blank and submit the form
Django will incorrectly save `foo`'s value to the DB as empty string
instead. It should be stored as `null`
--
Ticket URL: <https://code.djangoproject.com/ticket/31047>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by inoks):
I think empty HTML textarea send the value as an empty string instead of
null/None.
The only solution may be to set `disabled` attribute for the textarea. In
that case, the value for that field will not be submitted to the server
and `null` should be saved into the DB instead of the empty string.
--
Ticket URL: <https://code.djangoproject.com/ticket/31047#comment:1>
* status: new => closed
* version: 2.2 => master
* resolution: => duplicate
Comment:
This is a documented and expected behavior, see
[https://docs.djangoproject.com/en/dev/ref/models/fields/#null #null] and
[https://docs.djangoproject.com/en/dev/ref/models/fields/#blank #blank].
Duplicate of #9590.
--
Ticket URL: <https://code.djangoproject.com/ticket/31047#comment:2>