I want to add a new model to my current setup that will look like this
class Cinerama(models.Model):
memeber = models.ManyToManyField(Person)
#somethins
but problem is i don’t have a person model i have a boy and girl model like so
class Girls(models.Model):
#somethins only girls do
#many other fk
teacher = models.ForeignKey(Teacher)
class Boys(models.Model):
#somethins only boys do
#many other fk
teacher = models.ForeignKey(Teacher)
so i do not want to change the set up around so i want to add tags to both girls and boys then make a new person model so that the system will look like this
class Person(models.Model):
slug = models.SlugField()
class Cinerama(models.Model):
members = models.ManyToManyField(Person)
#somethins
class Girls(models.Model):
#somethins
teacher = models.ForeignKey(Teacher)
tag= models.ForeignKey(Person)
class Boys(models.Model):
#somethins
teacher = models.CharField()
tag= models.ForeignKey(Person)
will this be the best option to take or using generic.GenericForeignKey will be better and how will u retrieve all students that was taken to the Cinerama by a teacher with a pk=1,
A generic foreign key is required here. Their are other alternaives also e.g. create a person model and extend your boys and girls model from it. A generic relation can be created as:
Also add a reverse relation in your girl and boy model so that you can do
Girls.cinerama.all():