I have an ASP.NET Mvc application which will send a POST request to my Django website. Now I am getting CSRF verification failed. Request aborted.. How can I disable it.
            Asked
            
        
        
            Active
            
        
            Viewed 562 times
        
    2
            
            
        
        ferrangb
        
- 2,012
 - 2
 - 20
 - 34
 
        Imran Qadir Baksh - Baloch
        
- 32,612
 - 68
 - 179
 - 322
 
1 Answers
4
            Use @csrf_exempt decorator:
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def my_view(request):
    ...
        catavaran
        
- 44,703
 - 8
 - 98
 - 85
 
- 
                    Thanks. But I am getting `MultiValueDictKeyError ` when I do `request.POST['rml']` – Imran Qadir Baksh - Baloch Jan 20 '15 at 12:25
 - 
                    Thanks got it from http://stackoverflow.com/questions/5895588/django-multivaluedictkeyerror-error-how-do-i-deal-with-it – Imran Qadir Baksh - Baloch Jan 20 '15 at 12:29
 - 
                    1This error is thrown then there is no such parameter in `POST` data. Use `request.POST.get('rml')` instead. – catavaran Jan 20 '15 at 12:30
 - 
                    @warath-coder, its just a def and request.POST.get. Please try it – Imran Qadir Baksh - Baloch Jan 20 '15 at 12:49
 - 
                    it works perfectly fine for me; why i ask to see your exact code; the form as well that is sending the POST data. – warath-coder Jan 20 '15 at 12:59
 - 
                    I am saying I have nothing special just request.POST.get('rml'). If I remove @csrf_exempt then it will work otherwise not. – Imran Qadir Baksh - Baloch Jan 20 '15 at 13:32
 - 
                    id you wont post all your code (posting form and view file) there is nothing further we can do. as it works for me just fine. django 1.7.2 is my version – warath-coder Jan 20 '15 at 13:48