From 2e21c5789ed03c84e0ea59aad37f2a2764a730ec Mon Sep 17 00:00:00 2001 From: Michael Hall Date: Mon, 26 Mar 2018 19:23:12 -0400 Subject: [PATCH] Only try to use city in search form if it has a value --- get_together/views/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/get_together/views/__init__.py b/get_together/views/__init__.py index dd6292c..d385f55 100644 --- a/get_together/views/__init__.py +++ b/get_together/views/__init__.py @@ -101,7 +101,10 @@ def home(request, *args, **kwards): print("Error looking up nearby teams and events", err) traceback.print_exc() - search_form = SearchForm(initial={'city': city.id, 'distance': near_distance}) + initial_search = {'distance': near_distance} + if city is not None and city.id > 0: + initial_search['city'] = city.id + search_form = SearchForm(initial=initial_search) context['search_form'] = search_form return render(request, 'get_together/index.html', context)