1
0
Fork 0

search: Redirect directly to item page on single search result

This commit is contained in:
Piotr Dobrowolski 2017-12-13 20:02:55 +01:00
parent 0f6fe5002d
commit fe1c6685b0
1 changed files with 4 additions and 0 deletions

View File

@ -49,6 +49,10 @@ def search(request):
query = request.GET.get('q', '')
results = apply_smart_search(query, Item.objects)
if results.count() == 1:
return redirect(results.all()[0])
return render(request, 'results.html', {
'query': query,
'results': results.all(),