datamade / just-spaces

🏕 A tool from University City District and DataMade to promote better and more just public spaces
https://justspacesproject.org
MIT License
7 stars 1 forks source link

Standardize Django form validation #137

Open beamalsky opened 5 years ago

beamalsky commented 5 years ago

All forms should be using Django's form validation! Go over all forms carefully to turn off HTML5 validation and make sure Django's is working and displaying errors properly.

Wise words from @jeancochrane:

In general my philosophy about form validation is to err on the side of showing more errors, even if they're confusing, since then at least the user gets a signal that something's wrong and can follow up wtih us to let us know what it says. I also think that there's some value in not relying on HTML5 form validation and instead using Django's form validation, since using HTML5 validation splits the responsibility for form validation between the frontend and the backend instead of colocating it all in the same place.

On turning off HTML5 validation: https://docs.djangoproject.com/en/2.2/ref/forms/api/#django.forms.Form.use_required_attribute

Supersedes #31.

beamalsky commented 5 years ago

I did a little more reading on this (see this article), and HTML5 validation does seem pretty cool. I'm interested in trying it out in smaller projects, but as it's not easily compatible with the LeafletWidget (as it's not an input, select, or textarea element) I think we're making the right decision in using Django validation.