After I added the JWT functionality to my REST apis built using djangorestframework
, I have noticed these two models (BlacklistedToken
and OutstandingToken
) on my django admin panel that in the django admin panel, which I want to hide:
I already checked this question:
Hide the token table from the admin panel in Django REST Framework
Which is quite similar to the issue I have, except that since I’m using djangorestframework-simplejwt
I did the following on my admins.py
:
from django.contrib import admin
from rest_framework_simplejwt.token_blacklist.models import (
BlacklistedToken,
OutstandingToken,
)
# Unregister the blacklisted and outstanding token models
admin.site.unregister(BlacklistedToken)
admin.site.unregister(OutstandingToken)
and I get:
File "/home/couzhei/code/Map-of-defect/backend/venv/lib/python3.10/site-packages/django/contrib/admin/sites.py", line 153, in unregister
raise NotRegistered("The model %s is not registered" % model.__name__)
django.contrib.admin.exceptions.NotRegistered: The model BlacklistedToken is not registered
I even intentionally register
and then unregister
them, but it only removes the above exception, not hiding them. Any ideas would be appreciated.