summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--example_project/settings.py8
-rw-r--r--ishtar_common/middleware.py8
2 files changed, 16 insertions, 0 deletions
diff --git a/example_project/settings.py b/example_project/settings.py
index a76134746..553ea52f9 100644
--- a/example_project/settings.py
+++ b/example_project/settings.py
@@ -261,11 +261,19 @@ DOT_BINARY = ""
TEST_RUNNER = 'ishtar_common.tests.ManagedModelTestRunner'
+DISABLE_CSRF_CHECK = False # for testing purpose
+
try:
from local_settings import *
except ImportError, e:
print('Unable to load local_settings.py:', e)
+if DISABLE_CSRF_CHECK:
+ MIDDLEWARE.insert(
+ 'ishtar_common.middleware.DisableCsrfCheck',
+ MIDDLEWARE.index('django.middleware.csrf.CsrfViewMiddleware')
+ )
+
TABLE_COLS = {} # allow to overload table col settings on extra module
COL_LABELS = {}
diff --git a/ishtar_common/middleware.py b/ishtar_common/middleware.py
new file mode 100644
index 000000000..0c7dea825
--- /dev/null
+++ b/ishtar_common/middleware.py
@@ -0,0 +1,8 @@
+from django.utils.deprecation import MiddlewareMixin
+
+
+class DisableCsrfCheck(MiddlewareMixin):
+ def process_request(self, req):
+ attr = '_dont_enforce_csrf_checks'
+ if not getattr(req, attr, False):
+ setattr(req, attr, True)