1 回答

TA貢獻1735條經驗 獲得超5個贊
默認情況下, [?ListView
Django-doc]不會實現 POST 請求的處理程序。搜索通常通過 GET 請求完成,因此您應該使用:
<form class="box" action="{% url 'result' %}" method="GET">
? ? <h1>Product Check</h1>
? ? <p> Please enter the serial id of your product to check it.</p>
? ? <input type="text" name="q" placeholder="Serial Number">
? ? <input type="submit" placeholder="Check">
</form>
此外<input type="submit">不應該有name="q"屬性。
您還可以將文本框的類型更改為type="search"
[mozilla] :
<form class="box" action="{% url 'result' %}" method="GET">
? ? <h1>Product Check</h1>
? ? <p> Please enter the serial id of your product to check it.</p>
? ? <input type="search" name="q" placeholder="Serial Number">
? ? <input type="submit" placeholder="Check">
</form>
添加回答
舉報