# my .views
def search_view(request):
query = request.GET.get('q', None)
print(query)
context = {"query": query}
return render(request, 'view.html', context)
# .urls
path('search/', search_view)
# my view.html
{% if query %}
<p>Your query {{ query }}</p>
{% else %}
<form method="GET" action='/search/'>
<input type="search" name='q' placeholder="Search" aria-label="Search">
<button type="submit">Search</button>
</form>
{% endif %}
I'm new to Django and I'm following the docs, I looked over and over and seems right to me but I keep getting query=None. When I input a value in the search bar goes to http://127.0.0.1:8000/search/?q=value, but the query is always None. Please help a noob getting started.