'How to hide the Token model from rest_framework.authtoken in django admin panel

I tried to solve the problem using this two methods

from rest_framework.authtoken.models import Token
admin.site.unregister(Token)
-----
from rest_framework.authtoken.models import TokenProxy 
admin.site.unregister(TokenProxy)

But the response is a mistake that says "The model Token is not registered"



Solution 1:[1]

You have to remove rest_framework.authtoken from INSTALLED_APPS

Solution 2:[2]

I faced the same problem with Django==4.0.4 and djangorestframework==3.13.1. I had new Django project with DRF and even though I did not register the model Token it was showing up on the admin site.

When I click the Token link in the admin, it was redirect me to /admin/authtoken/tokenproxy/. So, instead of the Token model, unregister the TokenProxy model from admin site;

from rest_framework.authtoken.models import TokenProxy

admin.site.unregister(TokenProxy)

This solved my problem.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 FacuZ3
Solution 2 uedemir