我有以下搜索栏(包含在Bootstrap Navbar中):
<form class="form-inline my-2 my-lg-0 navbar-toggler-right" method = "GET" action = "{% url 'search' %}" >
{% csrf_token %}
<input class="form-control mr-sm-2" type="text" placeholder="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
处理'search'
网址的视图:
def search(request):
if request.method == "GET":
contents_of_search = request.GET
return HttpResponse(contens_of_search)
问题在于,无论何时在此搜索栏中搜索某些内容,它都会返回&#34; csrfmiddlewaretoken&#34;和搜索的内容。有谁知道如何解决这个问题?
答案 0 :(得分:1)
您需要在输入文本中添加requestVisibleBehind
属性,以便在request.GET
name