Do you have access to the Django backend code?
You could disable CSRF validation by applying the @csrf_exempt decorator to the 
corresponding view functions.
Maybe you could create a view that returns only the CSRF token (through AJAX?) 
that you can utilize as needed?

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Tom Gorup
Sent: Friday, September 22, 2017 8:46 AM
To: Django users
Subject: CSRF and API Calls

I'm having a bit of an issue. I'm attempting to utilize a Javascript/React App 
to interact with a Django backend without the use of templates (hence no 
{%csrftoken%} available). As I understand CSRF middleware, the CSRF token comes 
with the form on the GET and is provided in the POST; however, if I'm not 
utilizing the templates and the app is completely separate from Django.

How do I go about obtaining the CSRF token prior to making the POST/PUT/etc.?

Let me know if you need more context. Appreciate any assistance!
--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto:django-users@googlegroups.com>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/13ecce96-2de8-4a42-8b1e-3b98ccbae524%40googlegroups.com<https://groups.google.com/d/msgid/django-users/13ecce96-2de8-4a42-8b1e-3b98ccbae524%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d816ec0469d741649c4f2b9b2ab6fc90%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.

Reply via email to