I have two models than inherited from the same abstract base class.
I would expect to be able to get all instances from classes that are children of the base class with something like AbstractClass.objects.all()
Of course I could join queries on all children but that’s awful and it stops working if I add new children class.
Is this possible with Django ORM ? What would be the elegant solution ?
I have used django’s other inheritance methods because I hit the same problem you are running into. I’m not sure if there is an elegant solution. Ultimately, you need several queries done on the DB and for the results to be merged together. I can’t picture the ORM supporting that.
Here is my usual hackish approach for this situation:
Then, you can query the entire list like this: