Only try to use city in search form if it has a value
This commit is contained in:
parent
3d5046e0c4
commit
2e21c5789e
1 changed files with 4 additions and 1 deletions
|
@ -101,7 +101,10 @@ def home(request, *args, **kwards):
|
||||||
print("Error looking up nearby teams and events", err)
|
print("Error looking up nearby teams and events", err)
|
||||||
traceback.print_exc()
|
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
|
context['search_form'] = search_form
|
||||||
return render(request, 'get_together/index.html', context)
|
return render(request, 'get_together/index.html', context)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue