I am trying to process undefined number of filtering options given to a views (in a post request).
For example if we have a view:
def get_posts_by_category(request):
print request.POST
if request.POST:
categories = [Categories.objects\
.get(cat=item) for item in request.POST["category"].split(",")[:-1]]
so view takes a list of categories, which can consist from 1 – n items.
Could someone suggest how can I get all articles, with categories I’ve got from POST?
1 Answer