How to disable auto strip in Charfield in Django
In Django, when edit field in admin page or post data to forms, the leading and tailing whitespace in CharField
and TextField
are removed.
The reason is strip=True
parameter in forms.CharField
, which is added in Djagno 1.9. You can see the discussion in django tiket #4960 and here is source code. models.CharField
and models.TextField
use formfield()
to create form to interact with user, then both of them eventually create a forms.CharField