Skip to content Skip to sidebar Skip to footer

Csrf Error In Django After Removal Of Hidden Fields

I got some good advice on StackOverflow about how to remove all hidden fields using JavaScript. Submitting the form sends the user to /submit, calling the submit_form view. In my v

Solution 1:

The problem is that you remove the hidden CSRF-field and the solution is to not remove this field, you could probably do that with the jQuery selector to have it ignore that field with :not(input[name=csrfmiddlewaretoken]).

Btw, Django doesn't have a problem with unknown field names sent to the form-class, it will happily ignore them so the removal of the hidden fields tradeoff is very small.

Post a Comment for "Csrf Error In Django After Removal Of Hidden Fields"