code: def enforce_csrf(self, request):
          
          reason = CSRFCheck().process_view(request, None, (), {})
          if reason:
              # CSRF failed, bail with explicit error message
              raise exceptions.PermissionDenied('CSRF Failed: %s' % reason)
docs: Enforce CSRF validation for session based authentication.