What is the correct approach to access the related objects for the given below models:
class Person(models.Model):
name = models.CharField(max_length=128)
def __str__(self):
return self.name
class Review(models.Model):
name = models.CharField(max_length=128)
def __str__(self):
return self.name
def get_review_team(self):
return self.reviewteam_set.all()
class ReviewTeam(models.Model):
review = models.ForeignKey(Review, on_delete=models.PROTECT)
team_one = models.ManyToManyField(Person, related_name='teamone')
team_two = models.ManyToManyField(Person, related_name='teamtwo')
def __str__(self):
return self.review.name
How to access the
team_one and team_two
of ReviewTeam
set from Review object.get_review_team
?
Using values_list on the ReviewTeam set I am able to get the IDs but not the names.
Thanks
~