So I'm trying to get something very simple accomplished. I want to enter a term into my search box, and display it on the resulting page.
My HTML for the form is
<form method="get" action="/results/" class="navbar-form pull-right">
<input type="text" id="searchBox" class="input-medium search-query" name="q" placeholder="Search">
<input type="submit" class="btn" value="Search" >
</form>
The views.py looks like this:
def search(request):
query = request.GET['q']
t = loader.get_template('template/results.html')
c = Context({ 'query': query,})
return HttpResponse(t.render(c))
And finally the result template contains:
<div>You searched for: {{ query }} </div>
Here's the urls.py
urlpatterns = patterns('',
url(r'^home/$', 'search.views.home'),
url(r'^results/$', 'search.views.results'),
Nothing is showing up in the {{ query }}
space.