1👍
✅
I think you can use values_list
to return only the subcategory__name
.
Try something like
subcategories = ct.values_list('subcategory__name', flat=True).distinct()
1👍
If you need subcategories, you should query subcategories.
Subcategory.objects.filter(classified__in=ct)
- [Answered ]-Upgrading django 1.6 to 1.7. Is there any change in Generic relations for "related_name"?
- [Answered ]-Django getting database fields with one query
- [Answered ]-Python argparse does not parse images with wildcard
- [Answered ]-Generating unique random field in Django or PostgreSQL
- [Answered ]-Django-autocomplete-url invalid URL
Source:stackexchange.com