Re: How can I access attributes in intermediate class

2010-07-01 Thread cat in a tub
I found model inheritance may be a better solution: combine may model into one (Similar to views combining tables in database) Quote: Model inheritance in Django works almost identically to the way normal class inheritance works in Python. The only decision you have to make is whether you want t

Re: How can I access attributes in intermediate class

2010-06-29 Thread Alexandre González
I was intrigued so I did it, I get this solution: from models import User, Group, Membership def example(request): example_group_id = 1 #I create only one group to test, this is his id group = Group.objects.get(pk=example_group_id) for user in group.members.iterator(): #Get all user

How can I access attributes in intermediate class

2010-06-29 Thread cat in a tub
class User(models.Model): name = models.CharField(max_length=128) class Group(models.Model): name = models.CharField(max_length=128) members = models.ManyToManyField(User, through='Membership') class Membership(models.Model): person = models.ForeignKey(User) group = models.For