Ampersand在url中转换为%26

时间:2015-10-30 20:47:39

标签: django solr

我尝试在提交表单后,在网址中插入/连接,来自搜索查询的q和/或fq。这是我到目前为止尝试的代码:

& {$InstallationPath\$ApplicationId\$ApplicationId.exe install}

<input type="hidden" name="q" value="{{ content.params.q }}'{% verbatim %}&type={% endverbatim %}'{{request.GET.type}}" />

我也试过

<input type="hidden" name="q" value="{{ content.params.q }}&type{{request.GET.type}}" />

无济于事。基本上我想要最终的网址(即提交表单后地址栏中的内容)就像是

{% autoescape on %}

相反,我得到了

q=something&somethingelse

如何让模板输出&符号,而不是编码成%?

1 个答案:

答案 0 :(得分:0)

实际上我使用了javascript。

<form role = "form" id="filter" action="/search/" method="get">
<input type="text" name="something" id="something" ...>

[...]

$(document).ready(function() {
    $("#filter").submit(function(event) {
        event.preventDefault();       
        $this = $(this);
        var something = $('#something').val();

        var qstr = window.location.search;
        var url = qstr + '&something=' + something;
        };
        window.location.search = url;
    });
});
相关问题