diff --git a/nexus/media/js/nexus.js b/nexus/media/js/nexus.js index e02c289..5c3ac95 100644 --- a/nexus/media/js/nexus.js +++ b/nexus/media/js/nexus.js @@ -34,7 +34,8 @@ jQuery.ajaxSetup({ } if (!safeMethod(settings.type) && sameOrigin(settings.url)) { - xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')); + var cookieName = $('#nexus-constants').data('csrfCookieName'); + xhr.setRequestHeader("X-CSRFToken", getCookie(cookieName)); } } -}); \ No newline at end of file +}); diff --git a/nexus/templates/nexus/base.html b/nexus/templates/nexus/base.html index 5a547aa..eec1923 100644 --- a/nexus/templates/nexus/base.html +++ b/nexus/templates/nexus/base.html @@ -25,7 +25,10 @@ - + {% block head %} {% endblock %} diff --git a/nexus/templatetags/nexus_helpers.py b/nexus/templatetags/nexus_helpers.py index 8d65d6e..ce5d806 100644 --- a/nexus/templatetags/nexus_helpers.py +++ b/nexus/templatetags/nexus_helpers.py @@ -1,5 +1,6 @@ from django import template from django.utils.datastructures import SortedDict +from django.conf import settings import nexus from nexus import conf @@ -18,6 +19,11 @@ def nexus_version(): register.simple_tag(nexus_version) +def nexus_csrf_cookie_name(): + return settings.CSRF_COOKIE_NAME +register.simple_tag(nexus_csrf_cookie_name) + + def show_navigation(context): site = context.get('nexus_site', NexusModule.get_global('site')) request = NexusModule.get_request()