I'm trying to add a group to a Django user, and I just can't do that. The code is very simple:
group = Group.objects.get(name='mygroup') # Works
request.user.groups.add(group) # No error
However, after the addition request.user.groups is auth.Group.None (just like it was before the addition).
I get exactly the same behavior if I add the user through the group:
group.user_set.add(user)
I'm running this code as part of a unit test, if that makes a difference.
Aucun commentaire:
Enregistrer un commentaire