24👍
✅
The reason this error occurs is, the class Token
has already been registered with an admin class like this:
from django.contrib import admin
from rest_framework.authtoken.models import Token
class TokenAdmin(admin.ModelAdmin):
list_display = ('key', 'user', 'created')
fields = ('user',)
ordering = ('-created',)
admin.site.register(Token, TokenAdmin)
To change this, you first need to unregister
the old admin registration against the given class, and then register the new one.
Try this:
admin.site.unregister(Token) #First unregister the old class
admin.site.register(Token, AuthTokenAdmin) #Then register the new class
Source:stackexchange.com