Lets say, for the example, that I have several models like below:
class People(models.Model):
name = models.CharField()
class Job(models.Model):
salary = models.IntegerField()
employee = models.ForeignKey(People)
class Meta:
abstract : True
class Artist(Job):
# pass
class Vet(Job):
# pass
class Doctor(Job):
# pass
class Meta:
abstract : True
class Surgeon(Doctor):
# pass
And now, let's say, I want to get all jobs worked by one people.
I would like to do something like
Mister_Jack = People.objects.get(pk=1)
jobs = Mister_Jack.job_set.all()
But it's not working as Job is abstract and the "job_set" relation doesn't exist. There is an "artist_set", an "surgeon_set" , etc. But I don't want to list all possible jobs.
What is the best way to do that ?
Note: the People & Job model is only an example to illustrate the pb.