Migrated search from POST to GET

This commit is contained in:
Sebastian Lohff 2017-04-15 16:44:38 +02:00
parent 0c19a69f76
commit 429a772f57
3 changed files with 5 additions and 9 deletions

View File

@ -13,8 +13,7 @@
</p>
<p>
<form class="form navbar-form" method="post" action="{% url "whoisdb:search" %}">
{% csrf_token %}
<form class="form navbar-form" method="get" action="{% url "whoisdb:search" %}">
<input class="textinput form-control" type="text" name="q" placeholder="Search in DB">
<button class="btn btn-primary">Search</button>
</form>

View File

@ -7,8 +7,7 @@
<div class="panel-heading">Search {% if term %}for {{ term }} - {{ results|length }} result{{results|length|pluralize:"s" }}{% else %}database{% endif %}</div>
<div class="panel-body">
<p>
<form class="form" method="post" action="{% url "whoisdb:search" %}">
{% csrf_token %}
<form class="form" method="get" action="{% url "whoisdb:search" %}">
<input type="text" name="q" placeholder="Search in DB">
<button class="btn btn-primary">Search</button>
</form>

View File

@ -83,11 +83,9 @@ def showHandle(request, handle):
def searchObject(request):
results = None
term = None
if request.method == "POST":
term = request.POST.get("q", None)
if term:
results = findInDatabase(term)
term = request.GET.get("q", None)
if term:
results = findInDatabase(term)
return render(request, "whoisdb/search.html", {"results": results, "term": term})