From fe1c6685b0179572daaf92d61ab1cc1c40a1c4f9 Mon Sep 17 00:00:00 2001 From: Piotr Dobrowolski Date: Wed, 13 Dec 2017 20:02:55 +0100 Subject: [PATCH] search: Redirect directly to item page on single search result --- storage/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/storage/views.py b/storage/views.py index e19aa5c..f007229 100644 --- a/storage/views.py +++ b/storage/views.py @@ -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(),