#29912 closed Cleanup/optimization (wontfix)
Make CharField/TextField remove newlines from input
Reported by: | Jakub Kleň | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 2.1 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
It seems to me Django should automatically remove newlines from input type="text" fields. Browsers seem to prevent users from entering newlines in those types of fields, but that's not something we should rely on, and the behaviour should be consistent between Django and web browsers. It seems to me it applies to almost all django.forms.widgets.Input widgets.
Change History (2)
comment:1 by , 6 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Summary: | newlines in input type="text" fields → Make CharField/TextField remove newlines from input |
comment:3 by , 6 years ago
As a temporary solution, I implemented this change in django.forms.widgets.Input.value_from_datadict
as I think that's the right place for it. Seems like it's widget related to me, it's the widget that doesn't support newlines, and the implementation was really simple. I would be really happy to also see this change in Django.
I also started a discussion for this here:
https://groups.google.com/forum/#!topic/django-developers/w0lJf1KT1Gc
I don't think there would be consensus for Django to modify input like that -- see ticket:6362#comment:43, for example. Remember that input might come from APIs as well. You could write to the DevelopersMailingList if you want to get other opinions.