I'm sorry if this has been asked before, or has been documented somewhere, but I can't seem to find a way to do the following...
Say we have a NormalModel, which has a foreign key to a PolymorphicModel with children PolymorphicA and PolymorphicB. Is there a way to query NormalModel, based on the type of the polymorphic relation?
I would imagine something like NormalModel.objects.filter(Q(polymorphic_model___instance_of=PolymorphicA)), but since NormalModel has a normal manager, ___instance_of does not work. I could maybe hack around it with NormalModel.objects.filter(polymorphic_model__polymorphic_ctype_id=X) where I predetermine X, but I don't think that's how I should be doing things.
I'm sorry if this has been asked before, or has been documented somewhere, but I can't seem to find a way to do the following...
Say we have a
NormalModel, which has a foreign key to aPolymorphicModelwith childrenPolymorphicAandPolymorphicB. Is there a way to queryNormalModel, based on the type of the polymorphic relation?I would imagine something like
NormalModel.objects.filter(Q(polymorphic_model___instance_of=PolymorphicA)), but sinceNormalModelhas a normal manager,___instance_ofdoes not work. I could maybe hack around it withNormalModel.objects.filter(polymorphic_model__polymorphic_ctype_id=X)where I predetermineX, but I don't think that's how I should be doing things.