Re: Check if in query set...

2007-12-09 Thread radioflyer
Thanks Todd. That's what I needed. Thought it might be that simple. On Dec 9, 7:01 pm, "Todd O'Bryan" <[EMAIL PROTECTED]> wrote: > s = Student.objects.get(pk=student_id) > if user in s.parents.all(): > // the user is legit > else: > // user is not s's guardian > > On Dec 9, 2007 6:11

Re: Check if in query set...

2007-12-09 Thread Tim Chase
> I want to check if the currently logged in user has permission to edit > a particular student. > > s = Student.objects.get(pk=student_id) > parents = s.parents.all() > > And then check if logged in user.id matches against any of the parent > ids. Looks like you're interested in something

Re: Check if in query set...

2007-12-09 Thread Todd O'Bryan
s = Student.objects.get(pk=student_id) if user in s.parents.all(): // the user is legit else: // user is not s's guardian On Dec 9, 2007 6:11 PM, radioflyer <[EMAIL PROTECTED]> wrote: > > I have a m2m relationship between users (guardians) and students. > > I want to check if the

Check if in query set...

2007-12-09 Thread radioflyer
I have a m2m relationship between users (guardians) and students. I want to check if the currently logged in user has permission to edit a particular student. s = Student.objects.get(pk=student_id) parents = s.parents.all() And then check if logged in user.id matches against any of the parent