List Info

Thread: Stripping spaces from text fields in forms (forms.TextField)




Stripping spaces from text fields in forms (forms.TextField)
user name
2006-05-29 23:31:58
Stripping leading and trailing whitespace from text fields
in forms in
nearly always desirable, but Django doesn't handle this for
me.
There seems to be a hook built in for massaging input data
before it's
validated: FormField.prepare(). I tried subclassing
TextField like so:

class MyTextField(django.forms.TextField):
    def prepare(self, new_data):
        new_data = new_data.strip()

But since strings are passed by copy, this has no effect.

Any suggestions?
Do you think this functionality should be built into Django?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )