Created
March 18, 2020 04:15
-
-
Save ychennay/d6f45bbcc086e8c00e38c7238be8a507 to your computer and use it in GitHub Desktop.
permissions example
This file contains 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
# stolen from https://stackoverflow.com/questions/16655097/django-abstract-models-versus-regular-inheritance | |
class PermissionsMixin(models.Model): | |
""" | |
A mixin class that adds the fields and methods necessary to support | |
Django's Group and Permission model using the ModelBackend. | |
""" | |
is_superuser = models.BooleanField(_('superuser status'), default=False, | |
help_text=_('Designates that this user has all permissions without ' | |
'explicitly assigning them.')) | |
groups = models.ManyToManyField(Group, verbose_name=_('groups'), | |
blank=True, help_text=_('The groups this user belongs to. A user will ' | |
'get all permissions granted to each of ' | |
'his/her group.')) | |
user_permissions = models.ManyToManyField(Permission, | |
verbose_name=_('user permissions'), blank=True, | |
help_text='Specific permissions for this user.') | |
class Meta: | |
abstract = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment