I have a model that looks like the following:
class Loves(models.Model):
poll = models.ForeignKey(Poll)
choice_text = models.CharField(max_length=200)
user_name = models.CharField(max_length=200)
Data in the model looks like:
poll choice_text user
1 a mike
1 b mike
1 c james
2 a james
2 b melody
1 d mike
How do I output a list that looks like:
user tuples
mike (1,a),(1,b),(1,d)
james (1,c), (2,a)
melody (2,b)
Thanks.
1 Answer