We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8f73fe3 commit 2bb41eeCopy full SHA for 2bb41ee
djangojs/static/js/djangojs/django.js
@@ -19,8 +19,12 @@
19
*/
20
initialize: function() {
21
this.urls = window.DJANGO_JS_URLS;
22
- this.context = window.DJANGO_JS_CONTEXT;
23
- this.user = window.DJANGO_JS_CONTEXT.user;
+ this.set_context(window.DJANGO_JS_CONTEXT);
+ },
24
+
25
+ set_context: function(context) {
26
+ this.context = context;
27
+ this.user = context.user;
28
if (this.user) {
29
/**
30
* Equivalent to ``User.has_perm`` function.
@@ -31,6 +35,16 @@
31
35
}
32
36
},
33
37
38
+ /**
39
+ * Reload context and user
40
+ */
41
+ reload: function(callback) {
42
+ $.get(this.url('django_js_context'), function(context) {
43
+ Django.set_context(context);
44
+ callback();
45
+ });
46
47
34
48
49
* Equivalent to ``reverse`` function and ``url`` template tag.
50
0 commit comments