The issue seems to be the formfield method, this has lead to people
subclassing TextField to "fix" this addition to Django 1.9, for example:
{{{
class NonStrippingTextField(TextField):
"""A TextField that does not strip whitespace at the beginning/end of
it's value. Might be important for markup/code."""
def formfield(self, **kwargs):
kwargs['strip'] = False
return super(NonStrippingTextField, self).formfield(**kwargs)
}}}
Other people fix it in the form and override the admin form, this has
become a bit messy, it seems to be necessary to introduce a strip argument
to the TextField constructor, to avoid having to create custom field
types.
--
Ticket URL: <https://code.djangoproject.com/ticket/30077>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* type: Uncategorized => New feature
Comment:
Just to make it clear the `strip=True` option was added to
`forms.CharField` and not `db.CharField` like the report seems to imply.
Moving this option to the database layer has been discussed and rejected
when the option was added to the form layer so I doubt there's consensus
on adding an option to specialize `TextField` here given striping spaces
should be the desired behaviour in most cases just like with
`db.CharField`.
> Other people fix it in the form and override the admin form
Can't this be simply done with
[https://docs.djangoproject.com/en/2.1/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_overrides
formfield_overrides] or `formfield_for_dbfield`?
--
Ticket URL: <https://code.djangoproject.com/ticket/30077#comment:1>
* status: new => closed
* resolution: => invalid
--
Ticket URL: <https://code.djangoproject.com/ticket/30077#comment:2>
Comment (by Rob van der Linde):
Ah I see, I'll have to find a Wagtail specific fix, though I must say I do
find this feature added to Django 1.9 extremely annoying.
--
Ticket URL: <https://code.djangoproject.com/ticket/30077#comment:3>