Django how to display the object only after filtering?

Hello, need your help. In this code, the page displays all the objects in the model, there is a form in which they are filtered. I need to not initially displayed all of the objects and appeared only after filtration.
views.py
def abonstat(request):
 abons = Uslugi.objects.all()
 abform = AbonStatForm(request.GET)
 if abform.is_valid():
 if abform.cleaned_data['client']:
 abons = abons.filter(client_id=abform.cleaned_data['client'])
 return render(request, 'clients/abonstat.html',
 {'abons': abons, 'abform': abform})
June 26th 19 at 14:01
1 answer
June 26th 19 at 14:03
Solution
?
def abonstat(request):
 abons = {}
 abform = AbonStatForm(request.GET)
 if abform.is_valid():
 if abform.cleaned_data['client']:
 abons = Uslugi.objects.filter(
client_id=abform.cleaned_data['client'])
 return render(request, 'clients/abonstat.html',
 {'abons': abons, 'abform': abform})

Find more questions by tags DjangoPython