-
-
Notifications
You must be signed in to change notification settings - Fork 302
Description
Sorry in advance I wanted to label this an enhancement but the labels aren't showing up.
`class Project(PolymorphicModel):
topic = models.CharField(max_length=30)
class ArtProject(Project):
artist = models.CharField(max_length=30)
class ResearchProject(Project):
supervisor = models.CharField(max_length=30)
class ScienceProject(Project):
supervisor = models.CharField(max_length=30)
other_field = models.BooleanField()`
I may have missed this in the documentation but if two inherited models share a common field in this case the supervisor field shared by the Research and Science project is there a cleaner way to make a query on supervisor other than.
results = Project.objects.filter(Q(ResearchProject___supervisor="Bob") | Q(ScienceProject___supervisor="Bob"))
something like
results = Project.objects.instance_of(ResearchProject, ScienceProject).filter(supervisor="Bob")
or even better would be
results = Project.objects.filter(supervisor="Bob")