1 2 3 4 5 | # Register Model with ModelAdmin
for name, model_admin in globals().copy().iteritems():
if name.endswith("Admin"):
model = globals()[name[:-5]]
admin.site.register(model, model_admin)
|
More like this
- DRY Fieldsets by DrMeers 2 years, 11 months ago
- GeoDjango maps in admin TabularInlines by alanB 1 year, 7 months ago
- SSL Middleware for Webfaction by parlar 5 years ago
- testdata tag for templates by showell 3 years ago
- Active User Sorted ModelAdmin by daemondazz 2 years, 10 months ago
Comments
Ummm...
Is this too hard to do? It does involve an extra 20 characters per model but gives you freedom to customise as needed later on and explicitly states whats going on.
#
@aarond10ster
Your referring to old-forms admin. Django 1.0 alpha uses newforms-admin and has completely decoupled admin from the models.
#
Thanks for that. I wrapped your code in a function. Please see [snippet 1015] (http://www.djangosnippets.org/snippets/1015/)
AK
#