diff options
author | Piotr Dobrowolski <admin@tastycode.pl> | 2017-12-13 20:02:55 +0100 |
---|---|---|
committer | Piotr Dobrowolski <admin@tastycode.pl> | 2017-12-13 20:02:55 +0100 |
commit | fe1c6685b0179572daaf92d61ab1cc1c40a1c4f9 (patch) | |
tree | 49caa16c27826454aa706a466442cba4d2e46c4d | |
parent | 0f6fe5002d10af2ba1fcdf61377906591bac5225 (diff) | |
download | spejstore-fe1c6685b0179572daaf92d61ab1cc1c40a1c4f9.tar.gz spejstore-fe1c6685b0179572daaf92d61ab1cc1c40a1c4f9.tar.bz2 spejstore-fe1c6685b0179572daaf92d61ab1cc1c40a1c4f9.tar.xz spejstore-fe1c6685b0179572daaf92d61ab1cc1c40a1c4f9.zip |
search: Redirect directly to item page on single search result
-rw-r--r-- | storage/views.py | 4 |
1 files changed, 4 insertions, 0 deletions
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(), |