[Answer]-I try to get the group (manytomany) of user but throws me int() argument must be a string or a number, not 'ManyRelatedManager'

1👍

That’s because all method return a ManyRelatedManager which is basically a list in python. If you want to get the group and not the whole list you may do:

a = request.user.groups.all()[0]
print a
>>> <Group: jefes>

Watch it that this way you access the first element in the list. If the list doesn’t contains any elements this will yield Index out of bounds exception.

Hope this helps!

Leave a comment