Question

I have a django project and the forms are constructed in HTML rather than as a django object. I retrieve the values via a post class function in the view. Because I'm not constructing forms through django, do I need to sanitize the form data? If I need to sanitize the data, what django method can I use?

Thanks for your help!

Was it helpful?

Solution

There's no reason why you can't construct a Form class that respects the parameters of the HTML form. There's not really any magic to it. Django offers tools to generate the HTML pragmatically, but you don't have to use it.

You can leverage all the power of Django's form validation--just make sure the Form class fields align with the field names in your HTML and bind it to the POST data. If your Form's parameters change, you'll have to update the markup.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top