Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I validate HTML in Django templates during the development process?

I haven't used Django's and Python's built in testing capabilities yet, but I want to finally start... And one of the most obvious things that I'd like to keep in check during the entire development process is that all my pages validate in all possible scenarios.

What's the best way to do this?

like image 349
Monika Sulik Avatar asked Jun 21 '10 16:06

Monika Sulik


1 Answers

Good question. I haven’t done this myself, so hopefully there will be some better answers, but you might want to look into HTML validation middleware:

  • http://djangosnippets.org/snippets/1312/
  • http://lukeplant.me.uk/resources/djangovalidator/
  • http://bstpierre.org/Projects/HtmlValidatorMiddleware/

“in all possible scenarios” might be too much to ask for, depending on your app. For example if you make the next Facebook, and are thus accepting huge amounts of user data every day, something will come in at some point that breaks the validity of a page on your site.

As validation errors don’t tend to destroy functionality, it might be an acceptable approach to check with some limited test data, then react to errors as they come up. I believe this is known as stupidity-driven testing.

like image 200
Paul D. Waite Avatar answered Sep 30 '22 01:09

Paul D. Waite