Sunday, January 8, 2012

Re: Joining Tables



The user field is a foreign key to django auth User model. Each user is assigned to a group (django Auth Group model). I want to retrieve all the photos which belongs to users of a specific group. How can it be done?


from django.contrib.auth.models import Group

group = Group.objects.get(name='your_group')
users = group.user_set.all()

Haven't tested it, but I think that's what you want/need.


0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate