models.py 350 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
from django.contrib.auth.models import AbstractUser
from django.utils.functional import cached_property
from typing import List


class User(AbstractUser):
    @cached_property
    def cached_groups(self) -> List[str]:
        out = ["authenticated_user"]
        for group in self.groups.all():
            out.append(group.name)
        return out