Re: Proper way to strip whitespace from Charfields in a form in current version of Django?

2011-07-19 Thread Andre Terra
Why not add a custom clean_fieldname method to your class? Perhaps you
could dig into the original BaseModelForm and see how it constructs
validation, and override whatever is needed.

I'm on my phone atm, so I'll let you do the footwork alone, at least for now.


Cheers,
AT

On 7/19/11, br  wrote:
> There seems to be a raging and unresolved discussion about how to
> address the issue of stripping whitespace from form fields in future
> versions of Django over on the Developers group:
> http://groups.google.com/group/django-developers/browse_thread/thread/90352cc0da78390b
> .
>
> In the present, what is the proper place to strip whitespace?
>
> I've starting down this path:
>
> http://www.peterbe.com/plog/automatically-strip-whitespace-in-django-forms
>
> by setting up a BaseModelForm class, but i don't necessarily like the
> fact that I could have a field with "blank=False" that will still
> validate if you have an input of just whitespace, since apparently
> "clean" gets called after validation takes place.  Is the override of
> full_clean referenced in the comments the way around this then? Seems
> pretty hacky.
>
> Thanks
>
> Ben
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
Sent from my mobile device

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Proper way to strip whitespace from Charfields in a form in current version of Django?

2011-07-18 Thread br
There seems to be a raging and unresolved discussion about how to
address the issue of stripping whitespace from form fields in future
versions of Django over on the Developers group:
http://groups.google.com/group/django-developers/browse_thread/thread/90352cc0da78390b
.

In the present, what is the proper place to strip whitespace?

I've starting down this path:

http://www.peterbe.com/plog/automatically-strip-whitespace-in-django-forms

by setting up a BaseModelForm class, but i don't necessarily like the
fact that I could have a field with "blank=False" that will still
validate if you have an input of just whitespace, since apparently
"clean" gets called after validation takes place.  Is the override of
full_clean referenced in the comments the way around this then? Seems
pretty hacky.

Thanks

Ben

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.