python 3.x - Test post requests on django, csrf_token -
i trying test of post methods in django app, due csrf_token
, can not test without browser. used @csrf_exempt
decorator forget remove decorators in production. there better way this?
@csrf_exempt(in_debug_only=true)
so decorator active when application in debug mode. or there better way test post requests?
like selenium
might have methods that?
note: m using django 1.7.2 , python 3.4.1
inspired this answer:
you can add new file app, let's call disable_csrf.py:
class disablecsrf(object): def process_request(self, request): setattr(request, '_dont_enforce_csrf_checks', true)
then can edit settings.py add this:
if debug: middleware_classes += myapp.disable.disablecsrf
let me know if worked.
Comments
Post a Comment