Discussion:
Remove user permission
Gaurav Tomer
2018-12-03 15:30:48 UTC
Permalink
I was trying to remove permission of a user using remove utility as below -

user = User.objects.get(id=user_id)
user.user_permissions.remove("delete_polls")

Then it raises TypeError:invalid literal for int with base 10:
'delete_polls'


Do I need to pass index here?

As it sounds kind of static way to do so. Is there anything I am missing
here?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAAb%3DBQodEv2hZyi5aRka5oD_eQwCnkBxcpQz5cJpnHEc33o5DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Saurabh Agrawal
2018-12-03 15:39:14 UTC
Permalink
"user.user_permissions.remove" expects a permission object. Or the pk of
that object. Hence, the TypeError.
Post by Gaurav Tomer
I was trying to remove permission of a user using remove utility as below -
user = User.objects.get(id=user_id)
user.user_permissions.remove("delete_polls")
'delete_polls'
Do I need to pass index here?
As it sounds kind of static way to do so. Is there anything I am missing
here?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAAb%3DBQodEv2hZyi5aRka5oD_eQwCnkBxcpQz5cJpnHEc33o5DQ%40mail.gmail.com
<https://groups.google.com/d/msgid/django-users/CAAb%3DBQodEv2hZyi5aRka5oD_eQwCnkBxcpQz5cJpnHEc33o5DQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAL1UH0tmmGD7DfvSStABPQkce7_fJV31OGOCHLMKRNbrW2kcgw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...