Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to set default user group in django

from django.contrib.auth.models import User, Group
from django.db.models.signals import post_save
from django.dispatch import receiver

@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
    if created:
        instance.groups.add(Group.objects.get(name='group_name'))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #set #default #user #group #django
ADD COMMENT
Topic
Name
3+8 =