Guest User

Untitled

a guest
Aug 10th, 2018
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. How to insert the group_id of a user to 'auth_user_groups' table
  2. details = User(username = "somename",password = "somepassword", email = "email",
  3. first_name = "firstname",
  4. last_name = "lastname",
  5. is_staff = 0,
  6. is_active = 1,
  7. is_superuser = 0
  8. )
  9. details.save()
  10.  
  11. save = auth_user_groups(user_id=1,group_id = 5)
  12.  
  13. user = User.objects.get(id=1)
  14. group = Group.objects.get(id=5)
  15.  
  16. user.groups.add(group)
Add Comment
Please, Sign In to add comment