I have some models using django-polymorphic-model
eg.
class Article(PolymorphicModel):
...
class Blog(Article):
tags = ...
class Story(Article):
publish = ...
Normally if I get all articles, I just do Article.objects.all()
, however what if I want to get all articles that tags are empty? If I do Articles.objects.filter(tags__isnull=True)
it will break because other models don't have this field, I would like to include Story entries too, do I really have to split into 2 different queries and combine again?
OK After some digging for the documentation through issues, here is how to do it
Articles.objects.filter(Blog___tags__isnull=True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With