Search code examples
djangodjango-templatesmako

Mako csrf_token like in Django templates


I my recent Django-project I use mako templates.

About Cross Site Request Forgery CSRF.

In django templates there is the tag {% csrf_token %} to protect from hackers.

What about mako templates? Is there any analog of csrf_token or there is another protection mechanism???

Thanks!


Solution

  • There's some sample code at Django Snippets that looks to do this, although judging by the comments, you may need to fiddle a bit. If you have trouble, you basically want to make sure that you're duplicating the Django stock CSRF tag (click the link, start on line 87).