Answer the question
In order to leave comments, you need to log in
How to do filter merging in Django?
How to combine multiple filters in django?
If you just write it by hand, it looks like this:
bbs = Bd.objects.filter(par1=pk1).filter(par2=pk2)
Do the following:
filter1 and filter2 should be filled if pk1 and pk2 != 0
I.e. if pk2 !=0 then:
bbs = Bd.objects.filter(par1=pk1)
If pk1!=0 then:
bbs = Bd.objects.filter(par2=pk2)
I did this:
if pk1!= 0:
fp = '.filter(prepod='
filter_par1 = f'.filter(par1={pk1})'
bbs = f'Bd.objects.filter(par1={pk1})'
Answer the question
In order to leave comments, you need to log in
Judging by the text of the error, it does not occur at all when fetching from the database, but when searching for a route.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question