Sunday, January 6, 2019

default groups and permissions

i have a custom user model that i want to have 4 default groups depending on job title.

this is my model.py
  1 from django.contrib.auth.models import AbstractUser, UserManager, PermissionsMixin
  2 from django.db import models
  3 
  4 class WiggenUserManager(UserManager):
  5     pass
  6 
  7 class WiggenUser(AbstractUser):
  8     title_choices = (
  9         ('Försäljningschef', 'Försäljningschef'),
 10         ('Affärsområdeschef', 'Affärsområdeschef'),
 11         ('Ekonomi', 'Ekonomi'),
 12         ('Verkstad', 'Verkstad'),
 13         ('IT utvecklare', 'IT utvecklare')
 14     )
 15     objects = WiggenUserManager()
 16     dob = models.DateField(blank=True, null=True)
 17     employee_number = models.IntegerField(blank=True, null=True)
 18     title = models.CharField(max_length=30, choices=title_choices, blank=True, null=True)
 19     mobile = models.CharField(max_length=15, blank=True, null=True)
 20     phone = models.CharField(max_length=15, blank=True, null=True)
 21     salary = models.IntegerField(blank=True, null=True)

so when i add a new user with for example (title Verkstad) i want that user to belong to the group verkstad..

where do i add that new group and set its permissions? i read somewhere about signal but it didnt say what to import or where to add it

anyone got an idea? :)

thnx in advance :)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/17b1e7b9-61e1-4643-9679-653d138052c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment