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
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
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
3 matches
Mail list logo