Object Filter based on user input in template

I have a view that renders data related to a user in template. I am facing an issue with a couple queries but cannot understand the cause. Django documentation unfortunately does not provide example for what I am trying to do. here is what my view looks like:

@method_decorator(login_required, name='dispatch')
class SupplierPage(LoginRequiredMixin,APIView):
    def get(self, request, *args, **kwargs):
        query = request.GET.get('search_ress', None)
        print(query)
        context = {}

        
        Supplier = supplier.objects.filter(supplier = query)
       
        labels = Item.objects.filter(fournisseur = query).values_list("reference")[:10]
        default_items = Item.objects.filter(fournisseur = query).values_list("number_of_sales")[:10]
        label1s = Item.objects.filter(fournisseur = query).values_list('reference', flat=True)[:10]
        default_item1s = Item.objects.filter(fournisseur = query).values_list('number_of_orders_placed', flat=True)[:10]
        
            
        context.update({'Supplier' : Supplier, 'labels':labels, 'default_items':default_items,'label1s':label1s, 'default_item1s':default_item1s})


        return render(request, 'Supplier.html',context)

so what is going on is that query is working fine and in fact Supplier renders the proper data. but the ones below return empty.
here is what I get in the django log:

DEBUG (0.001) SET search_path = 'pierre','public'; args=None
DEBUG (0.001) SELECT "dashboard_item"."reference" FROM "dashboard_item" WHERE "dashboard_item"."fournisseur" IS NULL LIMIT 10; args=()
DEBUG (0.001) SET search_path = 'pierre','public'; args=None
DEBUG (0.001) SELECT "dashboard_item"."number_of_sales" FROM "dashboard_item" WHERE "dashboard_item"."fournisseur" IS NULL LIMIT 10; args=()
DEBUG (0.001) SET search_path = 'pierre','public'; args=None
DEBUG (0.001) SELECT "dashboard_item"."reference" FROM "dashboard_item" WHERE "dashboard_item"."fournisseur" IS NULL LIMIT 10; args=()
DEBUG (0.001) SET search_path = 'pierre','public'; args=None
DEBUG (0.001) SELECT "dashboard_item"."number_of_orders_placed" FROM "dashboard_item" WHERE "dashboard_item"."fournisseur" IS NULL LIMIT 10; args=()

and in gunicorn:

start 2020-08-25 11:08:17.905545
BOLSEIRA
<QuerySet [<supplier: supplier object (BOLSEIRA)>]>
<QuerySet ['372600', '372750', '372650', '372700', '289807', '372150', '289922', '289840', '289923', '372310']>
<QuerySet [62.0, 58.0, 74.0, 60.0, 1.0, 16.0, 1.0, 1.0, 1.0, 2.0]>
<QuerySet ['372600', '372750', '372650', '372700', '289807', '372150', '289922', '289840', '289923', '372310']>
<QuerySet [4.0, 4.0, 4.0, 5.0, 2.0, 4.0, 2.0, 2.0, 2.0, 2.0]>
start 2020-08-25 11:08:04.890776
None
<QuerySet []>
<QuerySet []>
<QuerySet []>
<QuerySet []>
<QuerySet []>
start 2020-08-25 11:08:06.306851
None
<QuerySet []>
<QuerySet []>
<QuerySet []>
<QuerySet []>
<QuerySet []>
None
<QuerySet []>
<QuerySet []>
<QuerySet []>
<QuerySet []>
<QuerySet []>
start 2020-08-25 11:08:08.460480

gunicorn log is very bizarre, it seems that in a first it works fine and then it stopped. So weird!

I have verified the sintax, the variable names, and also that there is data in the db, and everything is okay, at this point I am out of things to try. I am hoping that someone could see where I am messing up. Thanks!

It looks like you’re not passing the parameter in the subsequent requests.

Have you verified that the front end is issuing the proper request?
Your output seems to indicate that you’re not getting the query variable “search_ress” supplied to the view.

that’s what it seems to say but how come it works for Supplier, for this object, the query variable is working fine. ln the front end, when i make a search with search_ress, everything about Supplier comes back but not with the rests of the objects. Could there be something off with the way I structure the filter-value list query?

I’m not following what you’re trying to say here. What I’m seeing:

These five lines of output seem to correspond to the five queries listed below.

The following output appears to be coming from a second request.

exactly, that’s what I don’t understand, because in gunicorn log, that’s the log for one click you know, when i make ONE search, all of this comes in the log

So then I’d take a much closer look at the front end, because it appears that the client is issuing multiple requests. It doesn’t appear to be anything in the back end - or at least these particular symptoms don’t appear to be related to anything in your view.

Alright sounds good, I’ll investigate on that side.