Using a custom AdminSite subclass

31 views
Skip to first unread message

Oliver Kraitschy

unread,
Apr 2, 2020, 9:22:52 AM4/2/20
to Django users
Hello everybody,

I'm using a custom AdminSite subclass. But since the update from Django 2.0.13 to 2.2.12 I'm having problems to get it recognized when creating or running migrations.

This is what I have in hal/admin.py:

from django.contrib import admin

class HalAdminSite(admin.AdminSite):
   
# ...

admin_site
= HalAdminSite()
admin_site
.register(Profile)
# ...

This is what I have in hal/apps.py:

from django.contrib.admin.apps import AdminConfig

class HalAdminConfig(AdminConfig):
    default_site
= 'hal.admin.HalAdminSite'

This is what I have in settings.py:

INSTALLED_APPS = [
   
# ....
   
'hal.apps.HalAdminConfig',
   
# ...
]

Nevertheless I get the following exceptions when running makemigrations or migrate:

AttributeError: module 'hal.admin' has no attribute 'HalAdminSite'
ImportError: Module "hal.admin" does not define a "HalAdminSite" attribute/class

Any hints about how I can fix this? That would be really appreciated!.


Greetings
Oliver
Reply all
Reply to author
Forward
0 new messages