djangosnippets.org: Latest snippets posted by msandershttp://djangosnippets.org/users/msanders/2009-08-27T04:46:16.341894-05:00msandersgroup_required decorator
2009-08-27T04:46:16.341894-05:00msandershttp://djangosnippets.org/snippets/1703/<p>This snippet provides a @group_required decorator. You can pass in multiple groups, for example:</p>
<pre><code>@group_required('admins','editors')
def myview(request, id):
...
</code></pre>
<p>Note: the decorator is based on the snippet <a href="http://fragmentsofcode.wordpress.com/2008/12/08/django-group_required-decorator/">here</a> but extends it checking first that the user is logged in before testing for group membership - <a href="http://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.decorators.user_passes_test">user_passes_test</a> does not check for …</p>
Freely redistributable