An admin for model "CustomUser" has to be registered to be referenced by FolderAdmin.autocomplete_fields
I am trying to install
django-filer and after following the installation docs(pip install, add to
INSTALLED_APPS etc), when I try run my dev server I get the following error in the terminal...
ERRORS: <class 'filer.admin.folderadmin.FolderAdmin'>: (admin.E039) An admin for model "CustomUser" has to be registered to be referenced by FolderAdmin.autocomplete_fields. <class 'filer.admin.permissionadmin.PermissionAdmin'>: (admin.E039) An admin for model "CustomUser" has to be registered to be referenced by PermissionAdmin.autocomplete_fields.
As visible in the error output. I've extended the Django user model with
CustomUser. I have also extended
AdminSite to get custom urls in the admin. So perhaps extending these is causing the error. Any possible solution to this?
The error says
an admin has to be registered and I do have multiple superusers registered.
This error is occurring because the filer app is trying to use the CustomUser model in its admin interface, but it is not able to find a registered admin for that model. To fix this, you will need to create an admin class for your CustomUser model that is compatible with the filer app.
You can do this by subclassing filer.admin.permissionadmin.PermissionAdmin or filer.admin.folderadmin.FolderAdmin instead of the default admin.ModelAdmin class, and then registering your custom admin class with the CustomUser model.
For example, you can create a file named admin.py in your app directory and add the following code:
from django.contrib import admin from filer.admin.folderadmin import FolderAdmin from myapp.models import CustomUser class CustomUserAdmin(FolderAdmin): pass admin.site.unregister(CustomUser) admin.site.register(CustomUser, CustomUserAdmin)
This code is creating a custom admin class CustomUserAdmin that inherits from filer.admin.folderadmin.FolderAdmin and then registering it to the CustomUser model using the admin.site.register() method.
You should also be aware that subclassing filer.admin.folderadmin.FolderAdmin also requires subclassing filer.admin.permissionadmin.PermissionAdmin, so you may need to create another custom admin class that inherit from filer.admin.permissionadmin.PermissionAdmin and register it to CustomUser as well.