3

Im looking for a simple way to disable all the CSRF validation to can test my API in Postman.

Till now I have tried add @decorator csrf_exempt without success. I also tried create a disable.py file inside the app, but didn't work also.

Also I want desactivate for all requests, so some way to dont have to add the decorator everywhere. This a project that I just got, is already in Production, but I want to start to write Tests first in Postman, later TestCases.

All my views are using a "api_generics.CRUDGeneric",

the declaration of that class is:

class CRUDGeneric(mixins.CreateModelMixin, mixins.ListModelMixin, mixins.RetrieveModelMixin,
                  mixins.DestroyModelMixin, mixins.UpdateModelMixin, viewsets.GenericViewSet):

thanks is advice

3
  • May help stackoverflow.com/a/30875830/1507546 Commented Feb 14, 2017 at 15:04
  • I've try it, but it doesnt solve my problem, I got other errors Commented Feb 14, 2017 at 15:22
  • I think you should update your post with these errors Commented Feb 14, 2017 at 16:27

1 Answer 1

4

@62009030 you should be able to do what @smarber mentioned.. This could also work.. It is a traversed way to add csrf_exempt

from django.conf.urls import patterns, url
from django.views.decorators.csrf import csrf_exempt

import views

urlpatterns = patterns('',
    url('^asimpleurl/$', csrf_exempt(views.CRUDGeneric.as_view())),
    ...
)

This could be a work around for your problem..

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.