Django内置标签编码为'?'到“%3F”

时间:2019-10-25 19:19:00

标签: django django-templates

我正在尝试进行分页,以将?page={{ page_num }}传递到网址末尾。

这是我想要做的,这是输出:

        $('#prev-page').click(() => {
            window.location.pathname = "{% url 'xadmin:get_deposits' %}?page={{ page_no|add:'-1' }}"
        });
        $('#next-page').click(() => {
            window.location.pathname = "{% url 'xadmin:get_deposits' %}?page={{ page_no|add:'1' }}"
        });

预期网址: http://localhost:8000/xadmin/deposits/?page=1

实际网址: http://localhost:8000/xadmin/deposits/%3Fpage=1

1 个答案:

答案 0 :(得分:1)

尝试一下

 $('#prev-page').click(() => {
    window.location = "?page={{ page_no|add:'-1' }}"
  });
 $('#next-page').click(() => {
    window.location = "?page={{ page_no|add:'1' }}"
 });