Registration for newforms admin
|Reported by:||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Some points to registration for newforms admin:
- One project can have many application, one application can be part of many projects.
- One project can have several admins.
- One application can be used in several admins from one project.
- One application can be registered in one project and not registered in another project.
- One application can be used with default ModelAdmin in one project but with unknown customatization in another project.
- Explicit is better than implicit, magic is evil.
I would like to propose new conventions. There would be new files admin.py in some applications with method register. Example:
from django.contrib import admin from django.contrib.sites import models class SiteAdmin(admin.ModelAdmin): list_display = ('domain', 'name') search_fields = ('domain', 'name') def register(site): site.register(models.Site, SiteAdmin)
There would be admin.py in each project. Example:
from django.contrib import admin # Import admins from your or contrib applications. from django.contrib.auth import admin as auth_admin from django.contrib.sites import admin as sites_admin # Register admins from your or contrib applications. admin_site = admin.AdminSite() auth_admin.register(admin_site) sites_admin.register(admin_site)
And it would be called from urls.py. Example:
from django.conf.urls.defaults import * import admin urlpatterns = patterns('', ('^admin/(.*)', admin.admin_site.root), )
I say "is" but I mean "convention is".
Change History (10)
comment:1 Changed 9 years ago by
|Triage Stage:||Unreviewed → Design decision needed|