jqgrid ajax 请求参数,如何将csrf_令牌传递给jqgrid的editurl的post参数?

我在Django框架中使用JqGrid。这是JS:jQuery("#list").jqGrid({

url:'{% url views.manage.devicesajax %}',

datatype: 'json',

mtype: 'GET',

colNames:['DID', 'UDID', 'Owner', 'Name', 'First seen', 'Last seen'],

colModel :[

{name:'did', index:'did', width: 30, searchoptions:{sopt:['eq','ne','bw','cn']}},

{name:'udid', index:'udid', width: 120, editable: true, searchoptions:{sopt:['eq','ne','bw','cn']}},

{name:'d_owner', index:'d_owner', width: 70, editable: true, searchoptions:{sopt:['eq','ne','bw','cn']}},

{name:'d_name', index:'d_name', editable: true, searchoptions:{sopt:['eq','ne','bw','cn']}},

{name:'d_firstseen', index:'d_firstseen', width: 80},

{name:'d_lastseen', index:'d_lastseen', width: 80}],

pager: jQuery('#pager'),

rowNum:20,

rowList:[20,50,100],

sortname: 'did',

sortorder: "desc",

multiselect: true,

viewrecords: true,

imgpath: 'themes/basic/images',

caption: 'Devices list',

height: 330,

width: 1000,

onSelectRow: function(id) {

var id = $("#list").getRowData(id).message_id;

message_id = id;

},

editurl: "{% url views.manage.deviceseditajax %}"

});

当我在JqGrid中编辑行时,我从editurl得到错误:Forbidden (403)

CSRF verification failed. Request aborted.

这是因为csrf_令牌不会与其他数据一起传递给editurl。

如何将csrf_令牌添加到editurl的POST请求中?在

这段代码运行得很好(完整的jqgrid init):

^{pr2}$