-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thank you for your response, Cliff.
But the strip-command wasn't my problem. I wondered why Django let pass
these kind of invalid input and if there is an easy way to toggle this
behavior for the whole project. I could not find anything in the Django
docs.
Now I'm thinking of overwriting the to_python-Method of the models
charField-class.
Or are there better solutions?


Am 08.11.2010 21:55, schrieb J. Cliff Dyer:
> On Mon, 2010-11-08 at 12:21 -0800, Ralf wrote:
>> Hi,
>>
>> my users put values like 'Paul\t\t' per copy and paste into html-
>> formfields and suceeded, the values ended up in the database.
>> I wonder whether there is no build-in-validator to prevent these kind
>> of invalid input.
>>
>> Is there a cheap way to validate or strip these kind of input?
>>
> 
> Yep.  A string in python has a strip() method that will take any
> whitespace off the beginning and end of the string.
> 
>     >>> username = username.strip()
> 
> You can also specify characters to strip off.
> 
>     >>> username = ' abcd .,.'
>     >>> username = username.strip('.,')
>     >>> username
>     ' abcd '
> 
> You should really check out the python tutorial at
> http://docs.python.org/tutorial/
> 
> Cheers,
> Cliff
> 
> 


- -- 

Peschke IT-Beratung

Ralf Peschke
Hüffener Heide 3
32257  Bünde
Tel:   05223/ 97 89 07 90
Fax:   05223/ 97 89 07 99
Mobil: 0175/ 32 72 561
E-Mail: rpesc...@peschke-it.de

- --------------------------------------
Diese E-Mail könnte vertrauliche und/oder rechtlich geschützte
Informationen enthalten. Wenn Sie nicht der richtige Adressat sind oder
diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den
Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die
unbefugte Weitergabe dieser Mail sind nicht gestattet.

This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkzZEBQACgkQb2+5ZL6Nh6FJgACeNtfWTC3DNBx+2f2KCHKZt8GT
CwMAnixjz5w6GYSEzK6qfX4+iMaex3Ho
=DKYk
-----END PGP SIGNATURE-----

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.

Reply via email to