I have blog comment forms in Django and I would like to know the following:
- Should I add CSRF to the forms?
- If I want to use the simple “render_comment_form” method, how do I add it?
- If I can’t add it like that, what is the best practice for doing it?
Each tutorial or discussion on the subject seems to have a different approach, and I am not certain I understand how it all works.
My answer assumes that you are using Django 1.2:
render_comment_formtag and you will see, that thecsrf_tokenis already included. You can overwrite this template in your project and including the CSRF token into it is as easy as writing{% csrf_token %}into the form.