Answer the question
In order to leave comments, you need to log in
How to filter by unknown parameters in Django?
I have several parameters with values that can be selected for filtering.
The fact is that the admin can add other parameters and their values must also go into the get request and be processed on the server.
It looks something like this:
Country
*checkbox* USA
*checkbox* Germany
Resolution
*checkbox* 1920x1080
*checkbox* 5120x...
Other parameters
....
So I have several filters there and it will look something like:
products = Product.objects. filter(Q(country=request.GET.get('country') || Q(resolution=request.GET.get('resolution')) and so on
But how to make the parameters by which to filter become dynamic?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question