This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.contrib.auth.models import User, Group | |
| from rest_framework import permissions | |
| def is_in_group(user, group_name): | |
| try: | |
| return Group.objects.get(name=group_name).user_set.filter(id=user.id).exists() | |
| except Group.DoesNotExist: | |
| return False | |
| class HasGroupPermission(permissions.BasePermission): |