Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Form validation in django

I just started to use django. I came across forms and I need to know which one is the better way to validate a forms. Would it be using django forms or should we use javascript or some client side scripting language to do it?

like image 661
Vicky Avatar asked Jul 15 '09 12:07

Vicky


1 Answers

You should ALWAYS validate your form on the server side, client side validation is but a convenience for the user only.

That being said, Django forms has a variable form.errors which shows if certain form fields were incorrect.

{{ form.name_of_field.errors }} can give you each individual error of each field that's incorrectly filled out. See more here:

http://docs.djangoproject.com/en/dev/topics/forms/

like image 119
AlbertoPL Avatar answered Sep 28 '22 07:09

AlbertoPL