N
N
NikClik2018-06-11 23:53:04
Django
NikClik, 2018-06-11 23:53:04

How to programmatically assign a group to a user?

I have a problem, I can not find a user registration, in which, immediately upon registration, the user will automatically be assigned "Staff Status" and will write him to an existing group with his rights.
Please help, I've been struggling with this problem for a long time.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2018-06-12
@vintello

I'm afraid you will have to read about signals in jang for a long time and then take and stir up something terrible, like this

@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
    if created:
        Profile.objects.create(user=instance)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question