1👍
✅
This error is raised, when you try to post data outer than a django form.
The simple, but UNSAFE method is to add @csrf_exempt
before your views, like:
@csrf_exempt
def my_view(request):
pass
The not that simple method is written here: https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax
2👍
This is the solution i found:
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def my_view(request):
return HttpResponse('Hello world')
- [Django]-Django templates how loop through rows of a model
- [Django]-Product variants not reflecting updated quantity in Order Summary in a Django E-commerce Project
- [Django]-“select_for_update” called inside an atomic block still TransactionManagementError
- [Django]-Django get unique hours in a datetime field
Source:stackexchange.com