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', '')
boat_existing = [ (b.id, b.name) for b in \
Boat.objects.filter(name__icontains=name) ]
pprint(boat_existing)
Boat.objects.filter(name__icontains=name) ] \
if len(name) > 2 else []
boat_search_form = BoatSearchForm(
name=name,
choices=boat_existing)