Answer the question
In order to leave comments, you need to log in
Filtering to prioritize one category over another?
There are 2 tables - Posts and Categories. There is a many to many relationship between them. You need to get 3 Posts, 4 categories are involved in the filtering, but among the sample of these three Posts, at least one Post must correspond to the priority category. That is:
Category-0 (priority), Category-1, Category-2, Category-3 participate in the filtering.
As a result, you need to get at least 1 Post that has a connection with Category-0 and 2 more random Posts that match the filtering conditions.
How to determine the priority to the category I need?
Answer the question
In order to leave comments, you need to log in
Instead of complex filters, I would make one queriset for the priority category and one more for non-priority ones and use union
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question