djangorestframework-simplejwt: Can't delete users if using token blacklist app
I can’t delete a user from the admin when using the blackilst app. I get the following error:
Deleting the selected account would result in deleting related objects, but your account doesn't have permission to delete the following types of objects:
-outstanding token
I found out this is due to the has_delete_permission in token_blacklist/admin.py being overwritten and set to false.
Is there a reason for this? Thanks
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 31 (11 by maintainers)
This also worked for us, thanks for the workaround! Below is a concrete example of what needs to happen inside of
admin.pyThis is my highly questionable solution until now: I have the following in my User ModelAdmin
I can recommend what @adriangzz commented, but instead of doing it in your virtual environment, I’d recommend using this resource: https://stackoverflow.com/a/9322007
Essentially, deregister our class, inherit the class for your custom code, then register it with the admin.
Still seems to be an issue.
Sorry for this issue taking so long to resolve. Unfortunately, David has relieved ownership to Jazzband maintainers, and (fortunately) the head is now @auvipy from the celery project. The unfortunate part is I’ve never got an answer from David, so I’ll try to debug the past and figure out how to go about this. In the meantime, @auvipy, do you mind taking a look at this issue, #267, and what we should do? Thanks!
A quick fix can be obtained by going to your environment packages and navigating to
rest_framework_simplejwt/token_blacklist/admin.pyand settingdef has_delete_permission(self, *args, **kwargs): return Falseto TrueWhen this will be solved, @Andrew-Chen-Wang?
@adriangzz It’s become a huge annoyance for a lot of people. I’ll look into the commit history and find out when this happened. If you don’t mind also helping me search through the file’s history, that’d be helpful.
Edit: nvm found it 3648e642ffed493918c40a450015ae098b77ed19
That way, I can file a regression report to perhaps remove it. At this point, I can’t really give a solid answer myself.
This worked, thank you.
Definitely a better solution than mine, I’m always amazed by the things you can do in Django.
This worked. Thank you Andrew.
Yes, can confirm that too.