[Answer]-How and where to generate a CSRF token for to make requests to a Django app through a REST API?

1👍

I had to add the decorator from django.views.decorators.csrf import ensure_csrf_cookie to my function to make it returns a CSRF token.

👤jul

0👍

Django documentation speaks on this here: https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax

An alternative is to use a framework like http://www.django-rest-framework.org/api-guide/authentication

Leave a comment