Re: Is the user member of a certain group

2010-02-22 Thread Joakim Hove
Thank you both; it works! Joakim On Feb 23, 12:27 am, Andy McKay wrote: > On 2010-02-22, at 2:56 PM, Joakim Hove wrote: > > > Any tip on how to write the "user_is_member_of_admin_group()" > > function? > > You can access the groups via the ManyRelatedManager, which exposes a

Re: Is the user member of a certain group

2010-02-22 Thread Andy McKay
On 2010-02-22, at 2:56 PM, Joakim Hove wrote: > Any tip on how to write the "user_is_member_of_admin_group()" > function? You can access the groups via the ManyRelatedManager, which exposes a queryset: user.groups.filter(...) eg: if user.groups.filter(name="Admin") -- Andy McKay, @clearwind

Re: Is the user member of a certain group

2010-02-22 Thread Tim Shaffer
There may be a more efficient way, but you can use this for starters: if ( "admin" in request.user.groups.values_list("name",flat=True) ): On Feb 22, 5:56 pm, Joakim Hove wrote: > Hello, > > using the django auth framework I have created two groups called > "admin" and

Is the user member of a certain group

2010-02-22 Thread Joakim Hove
Hello, using the django auth framework I have created two groups called "admin" and "normal" and all the users are members of either of these groups. Now when a user is authenticated I would like to render different views depending on which group the user is member of, something like this: if