textarea, max_length and \r\n

Skip to first unread message

eka (Esteban)

Jun 25, 2010, 10:34:01 PM6/25/10
to Django users
Hi all

I created a form with a textarea that has a max_length of 1024, this
textarea is rendered in frontend with a Javascript character counter,
what is odd is that the counter was giving the right length, in this
case 1024 and the form was failing in the max_length... debugging I
came to see that the Form is receiving the \n as \r\n in the POST data
for it.
So the length if failing cause '\r\n' counts as 2 intead of 1.

Searching on the internet I found out that it seems that the textarea
sends \r\n instead of \n. Is there any way to deal with this in

For now I will remove the max_length and make my own clean method for
this case.



eka (Esteban)

Jun 25, 2010, 11:09:34 PM6/25/10
to Django users
By now I made my own TextAreaField that will replace('\r\n', '\n') in
the to_python method
Reply all
Reply to author
0 new messages