1👍
✅
Event.objects.exclude(
id__in=TicketedConcert.objects.values_list('id', flat=True)
)
“My intention was to prevent the TicketedConcert subclass objects from being included in the parent class’s results.”
TicketedEvent.objects.exclude(
id__in=TicketedConcert.objects.values_list('id', flat=True)
)
I’m not sure if this is the best solution to work with instances. eg:
if tevent.id in TicketedConcert.objects.values_list('id', flat=True):
# the event is a concert
else:
# the event is not a TicketedConcert
But, it will work and not be too horribly unperformant (maybe).
Source:stackexchange.com