1👍
✅
The group assignment can occur during a post_save
signal on a User (i.e., after a user is created), or as you suggest, after a user registration form gets saved within a view. You can initialize the group right as you’re assigning the user to the group, using get_or_create
. For example:
def assign_group_to_newly_registered_users(sender, instance, **kwargs):
group, created = Group.objects.get_or_create(name='Newly Registered Users')
group.user_set.add(instance)
post_save.connect(assign_group_to_newly_registered_users, sender=User, dispatch_uid=__file__)
Source:stackexchange.com