Search form return results in browse


#1

Am I correct in thinking the section on ‘Setting Up Basic Browse Page’ allows for a search form to return results with the default view we built? I am trying to place a search bar in the header of my base.html, but am struggling with returning the browse results with the query. Should this be accomplish-able through the View we built? If not, I tried the following:

views.py

def browse_by_name(request, initial=None): 
	query_string = ''
	found_entries = None
	if ('q' in request.GET) and request.GET['q'].strip():
		query_string = request.GET['q']
		entry_query = utils.get_query(query_string, ['payment', 'specialty',])
		things = Thing.objects.filter(entry_query)
		return render(request, 'search/search.html', { 'query_string': query_string, 'things': things })
	else:
		if initial:
			things = Thing.objects.filter( 
				name__istartswith=initial).order_by('name')
		else:
			things = Thing.objects.all().order_by('name')
	 
		return render(request, 'search/search.html', { 
			'things': things, 
			'initial': initial,
})

index.html

    <form action="listing_page.html" class="hero-search-form">
       <div class="search-item">
            <div class="fltp">
                <input type="text" value="" name="q">
                <label class="placeholder" data-big-placeholder="Where do you want to be?" data-little-placeholder="Where?"></label>
            </div>
       </div>
        <div class="search-item"> 
            <button class="button-sq hero-search-button">
                    <a href="{% url 'browse' %}"></a>
                    <i class="icon icon-search">
                    	
                    </i>
            </button onclick="searchform.submit()">
        </div>
    </form>

#2

Welp, figured out stupid mistake…

Wrong url tag in action


#3

Ahh sorry for the delayed response, I was at a conf/on a plane the last few days! Glad you figured it out :)