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
- testdata tag for templates by showell 4 years ago
- GeoDjango maps in admin TabularInlines by alanB 2 years, 7 months ago
- DRY Fieldsets by DrMeers 3 years, 11 months ago
- Modeli18n by pavl 2 years, 11 months ago
- Custom admin widgets by field type by dgouldin 4 years, 2 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
#