search boats only if len(name) > 2

This commit is contained in:
maxime 2019-06-23 17:29:54 +02:00
parent 951a325293
commit 2729011946

View File

@ -21,8 +21,9 @@ def new_stay(request):
name = request.POST.get('search_name', '') name = request.POST.get('search_name', '')
boat_existing = [ (b.id, b.name) for b in \ boat_existing = [ (b.id, b.name) for b in \
Boat.objects.filter(name__icontains=name) ] Boat.objects.filter(name__icontains=name) ] \
pprint(boat_existing) if len(name) > 2 else []
boat_search_form = BoatSearchForm( boat_search_form = BoatSearchForm(
name=name, name=name,
choices=boat_existing) choices=boat_existing)