jQuery重定向后未显示Django消息

时间:2018-12-22 09:23:56

标签: python jquery django

我有风景

def approval(request, id):
 if request.method == "POST":
    messages.add_message(request, messages.INFO, 'You have activity was recorded')
    return HttpResponse({"success": "ok"})
 else:
    return HttpResponse(request.method + " not allowed")

对上面视图的ajax调用看起来像

$.ajax({
  url: url,
  type: "POST",
  data: {"comment": comment, csrfmiddlewaretoken: '{{ csrf_token }}'},
  success: function (data) {
      location.href = "/redirect_url/";
  }

});

但是,该消息在jquery URL /redirect_url上不可见。

0 个答案:

没有答案