#30402: Django default_site admin configuration doesn't register anything --------------------------------+-------------------------------------- Reporter: Przemek Pawlas | Owner: nobody Type: Bug | Status: new Component: contrib.admin | Version: master Severity: Normal | Resolution: Keywords: | Triage Stage: Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 --------------------------------+-------------------------------------- Changes (by rminderhoud):
* status: closed => new * resolution: worksforme => Comment: Hello, I believe there is still a bug here but I am not familiar enough with the django internals to pinpoint it. I have a similar issue as Przemek where using a custom `AdminSite` and overriding `default_site` works except that any newly registered models do not appear in the admin. It would seem the current test passes since the new class is indeed used but there is no test case to validate that the registry is correct. Here is an example of my setup: **settings.py** {{{ INSTALLED_APPS = [ "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", "myproject.apps.AdminConfig", "myproject.apps.AppConfig", ] }}} **apps.py** {{{ from django.apps import AppConfig as DefaultAppConfig from django.contrib.admin.apps import AdminConfig as DefaultAdminConfig class AdminConfig(DefaultAdminConfig): default_site = "myproject.admin.AdminSite" class AppConfig(DefaultAppConfig): name = "myproject" verbose_name = "MyProject" }}} **admin.py** {{{ from django.contrib import admin from .models import MyModel class AdminSite(admin.AdminSite): pass class MyModelAdmin(admin.ModelAdmin): pass admin.site.register(MyModel, MyModelAdmin) }}} Seemingly, everything is configured correctly as per the documentation. However, if we inspect the registry at the end of `admin.py` and then again in `urls.py` I notice that they don't match. Command: {{{ print(admin.site._registry) }}} {{{ Registry in admin.py {<class 'myproject.models.MyModel'>: <myproject.admin.MyModelAdmin object at 0x7f5e5bc90fd0>} }}} {{{ Registry in urls.py {<class 'django.contrib.auth.models.Group'>: <django.contrib.auth.admin.GroupAdmin object at 0x7f5e5bc9c7f0>, <class 'django.contrib.auth.models.User'>: <django.contrib.auth.admin.UserAdmin object at 0x7f5e5bc48780>} }}} -- Ticket URL: <https://code.djangoproject.com/ticket/30402#comment:3> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/069.77070194382b4d6b589c2815d6bf8e95%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.