I have a Person model.
class Person(models.Model):
name_first = models.CharField(max_length=100)
name_middle = models.CharField(max_length=100, null=True, blank=True)
name_last = models.CharField(max_length=100)
date_birth = models.DateField(null=True, blank=True)
date_death = models.DateField(null=True, blank=True)
I'm trying to extend it to different roles in the music world: a composer, a performer, and a patron.
A person can be one, two or all three roles. If a person is a performer, I also need to assign one or more instrument for that person. You may not know if a person is a performer at the time of instantiation. Or their roles can change over time.
I want to be able to search and display that a person is a composer, pianist and a patron, if he's all three. For example: Beethoven is a conductor, composer, and pianist.
My initial thought on implementation is to inherit the Person class.
class Composer(Person):
pass
class Performer(Person):
instrument = models.ManyToManyField(Instrument, verbose_name=_('instrument'), blank=True,)
class Patron(Person):
pass
class Instrument(models.Model):
name = models.CharField(max_length=100, null=True, blank=True)
Question 1: should I use some sort of abstract model instead? If so, how would I go about it?
Question 2: how can I search for a person and know whether they are a composer, patron and/or performer and the kind of performer they are.
Thanks.