[Answered ]-Get foreign key value for queried object in Django

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)

Leave a comment