2014-05-26 18:33 GMT-03:00 Daniele Procida <daniele@vurt.org>:
I've an application that's been happily running for a few years, that does this:
class Person(Model):
# everyone's a Person
class Researcher(Model):
# a Researcher is Person who publishes research
person = models.OneToOneField(Person)
class Publication(Model):
author = models.ForeignKey(Researcher)
But this is no longer enough: now I also need to distinguish between Researchers who are research students and members of staff. Those who are students will need new fields such as "thesis_title" and "supervisors".
But, I will *still* need the Researcher class independently of the new ResearchStudent and ResearchStaff classes, because it's needed for Publication.author.
So now it might look something like this:
class Person(Model):
# everyone's a Person
class Researcher(Model):
# a Researcher is Person who publishes research
person = models.OneToOneField(Person)
class ResearchStaff(Model):
researcher = models.OneToOneField(Researcher)
class ResearchStudent(Model):
researcher = models.OneToOneField(Researcher)
supervisors = models.ManyToManyField(ResearchStaff)
So, a ResearchStudent must be a Researcher and can have multiple supervisors, but every supervisor must to be a ResearchStaff and a Researcher too; and everyone is a Person here. Right?
Can a ResearchStudent be a ResearchStaff too?
i'll do something like this:
class Publication(Model):
author = models.ForeignKey(Researcher)
How manageable is this going to be? Is there a better way of doing what I need to do, perhaps through inheritance?
Thanks,
Daniele
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20140526213320.1042853662%40mail.wservices.ch.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJJc_8U-FaX5PtQppji1kKrn259%2BtEwZCR9AdFqDUTecwdyJ_Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment