File tree Expand file tree Collapse file tree 5 files changed +20
-3
lines changed Expand file tree Collapse file tree 5 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -7,3 +7,6 @@ def media(request):
7
7
Adds media-related context variables to the context.
8
8
"""
9
9
return {'CMS_MEDIA_URL' : get_cms_setting ('MEDIA_URL' )}
10
+
11
+ def csrf_cookie_name (request ):
12
+ return {'CSRF_COOKIE_NAME' : settings .CSRF_COOKIE_NAME }
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ $.ajaxSetup({
34
34
}
35
35
if ( ! ( / ^ h t t p : .* / . test ( settings . url ) || / ^ h t t p s : .* / . test ( settings . url ) ) || base_doc_url == base_settings_url ) {
36
36
// Only send the token to relative URLs i.e. locally.
37
- xhr . setRequestHeader ( "X-CSRFToken" , getCookie ( 'csrftoken' ) ) ;
37
+ xhr . setRequestHeader ( "X-CSRFToken" , getCookie ( csrf_cookie_name ) ) ;
38
38
settings . csrfTokenSet = true ;
39
39
}
40
40
}
@@ -81,7 +81,7 @@ base_settings_url = base_settings_url[0];
81
81
}
82
82
if ( ! ( / ^ h t t p : .* / . test ( settings . url ) || / ^ h t t p s : .* / . test ( settings . url ) ) || base_doc_url == base_settings_url ) {
83
83
// Only send the token to relative URLs i.e. locally.
84
- xhr . setRequestHeader ( "X-CSRFToken" , getCookie ( 'csrftoken' ) ) ;
84
+ xhr . setRequestHeader ( "X-CSRFToken" , getCookie ( csrf_cookie_name ) ) ;
85
85
settings . csrfTokenSet = true ;
86
86
}
87
87
}
Original file line number Diff line number Diff line change 58
58
}
59
59
if ( ! ( / ^ h t t p : .* / . test ( settings . url ) || / ^ h t t p s : .* / . test ( settings . url ) ) || base_doc_url == base_settings_url ) {
60
60
// Only send the token to relative URLs i.e. locally.
61
- xhr . setRequestHeader ( "X-CSRFToken" , getCookie ( 'csrftoken' ) ) ;
61
+ xhr . setRequestHeader ( "X-CSRFToken" , getCookie ( csrf_cookie_name ) ) ;
62
62
settings . csrfTokenSet = true ;
63
63
}
64
64
}
Original file line number Diff line number Diff line change 5
5
6
6
{% block extrahead %}
7
7
{{ block.super }}
8
+ < script type ="text/javascript ">
9
+ var csrf_cookie_name = "{{CSRF_COOKIE_NAME|default:'csrftoken'}}" ;
10
+ </ script >
8
11
< script type ="text/javascript " src ="{{ STATIC_URL }}cms/js/csrf.js "> </ script >
9
12
< script type ="text/javascript " src ="{% url 'admin:jsi18n' %} "> </ script >
10
13
Original file line number Diff line number Diff line change @@ -506,6 +506,17 @@ If you have a huge site you can easily partition the menu with this.
506
506
Advanced Settings
507
507
*****************
508
508
509
+ CSRF_COOKIE_NAME
510
+ =================
511
+
512
+ In case you've overwritten the default Django `CSRF_COOKIE_NAME ` setting, then you should
513
+ inform Django-CMS about this by using a context processor dedicated for this. Extend the list
514
+ of `TEMPLATE_CONTEXT_PROCESSORS ` with
515
+
516
+ .. code-block :: python
517
+
518
+ ' cms.context_processors.csrf_cookie_name' ,
519
+
509
520
.. setting :: CMS_PERMISSION
510
521
511
522
CMS_PERMISSION
You can’t perform that action at this time.
0 commit comments