how to set default user group in django

Solutions on MaxInterview for how to set default user group in django by the best coders in the world

showing results for - "how to set default user group in django"
Norah
26 Oct 2016
1from django.contrib.auth.models import User, Group
2from django.db.models.signals import post_save
3from django.dispatch import receiver
4
5@receiver(post_save, sender=User)
6def create_user_profile(sender, instance, created, **kwargs):
7    if created:
8        instance.groups.add(Group.objects.get(name='group_name'))
9