Created
June 5, 2018 20:23
-
-
Save theparadoxer02/59588e2de319c31fdd6d59a3a57737c5 to your computer and use it in GitHub Desktop.
Users models with custom permissions used in the blog https://medium.com/@theparadoxer02/user-groups-with-custom-permissions-in-django-9eaea67b220e
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 AbstractUser | |
from django.utils import timezone | |
from django.db import models | |
class User(AbstractUser): | |
"""Define the extra fields related to User here""" | |
first_name = models.CharField(_('First Name of User'), blank = True, max_length = 20) | |
last_name = models.CharField(_('Last Name of User'), blank = True, max_length = 20) | |
# - - - Some more User fields according to your need s | |
# This is the most important part to look upon to define the custom permissions related to User. | |
class Meta: | |
permissions = (("can_go_in_non_ac_bus", "To provide non-AC Bus facility"), | |
("can_go_in_ac_bus", "To provide AC-Bus facility"), | |
("can_stay_ac-room", "To provide staying at AC room"), | |
("can_stay_ac-room", "To provide staying at Non-AC room"), | |
("can_go_dehradoon", "Trip to Dehradoon"), | |
("can_go_mussoorie", "Trip to Mussoorie"), | |
("can_go_haridwaar", "Trip to Haridwaar"), | |
("can_go_rishikesh", "Trip to Rishikesh")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment