1👍
✅
You can get all the relevant categories as following:
relevant_categories = DownloadableResourceCategory.objects.filter(
downloadableresource__in=items).distinct()
Do note the use of distinct()
since it is a m2m relationship you can get category multiple times. distinct
will only return the unique categories in this case.
👤AKS
Source:stackexchange.com