How would I add a user to a group in django by the group’s name?
I can do this:
user.groups.add(1) # add by id
How would I do something like this:
user.groups.add(name='groupname') # add by name
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Find the group using Group model with the name of the group, then add the user to the user_set