Skip to content

Instantly share code, notes, and snippets.

@h4
Created May 23, 2012 08:20
Show Gist options
  • Save h4/2773863 to your computer and use it in GitHub Desktop.
Save h4/2773863 to your computer and use it in GitHub Desktop.
Проверка вхождения пользователя в группу в Django
if not request.user.is_authenticated():
return redirect('/login/?next=%s' % request.path)
else:
for group in request.user.groups.values_list():
if (u'profsoux' in group) or request.user.is_staff:
break
else:
if not request.user.is_staff:
return render(request, 'denied.html', {})
@dketov
Copy link

dketov commented May 23, 2012

вЧоНадо = reduce(lambda (id, name), tail: name == 'чонадо' or False, request.user.groups.values_list())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment