2015-10-30 36 views
0

我試圖把/連接在URL中,一旦表單被提交,從搜索查詢q和/或fq。這是到目前爲止,我已經試過代碼:&符號轉換爲%26在url

<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 

相反,我得到

q=something%26type%3Dsomethingelse 

我怎樣才能獲得模板來輸出和號和等號,因爲它們不被編碼到%中?

回答

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; 
    }); 
});