Hi all, I wanted to use edit_inline for some of my models, but wanted to customise the templates that were used.
So I modified the admin app to let you override the edit inline templates in your own applications, using the admin/app_name/model_name/edit_inline_(stacked|tabular).html convention that the other admin templates use. The diff is below. Hope it's useful to someone, it's extremely useful for me! Cheers, MikeH Index: django/contrib/admin/templatetags/admin_modify.py =================================================================== --- django/contrib/admin/templatetags/admin_modify.py (revision 7092) +++ django/contrib/admin/templatetags/admin_modify.py (working copy) @@ -145,7 +145,9 @@ self.show_url = original and hasattr(self.relation.opts, 'get_absolute_url') def template_name(self): - return "admin/edit_inline_tabular.html" + model_name = self.relation.model._meta.object_name.lower() + app_name = self.relation.model.__module__.split('.')[-2].lower() + return ["admin/%s/%s/edit_inline_tabular.html" % (app_name, model_name), "admin/edit_inline_tabular.html"] class StackedBoundRelatedObject(BoundRelatedObject): def __init__(self, related_object, field_mapping, original): @@ -157,7 +159,9 @@ self.show_url = original and hasattr(self.relation.opts, 'get_absolute_url') def template_name(self): - return "admin/edit_inline_stacked.html" + model_name = self.relation.model._meta.object_name.lower() + app_name = self.relation.model.__module__.split('.')[-2].lower() + return ["admin/%s/%s/edit_inline_stacked.html" % (app_name, model_name), "admin/edit_inline_stacked.html"] class EditInlineNode(template.Node): def __init__(self, rel_var): @@ -175,7 +179,7 @@ original = context.get('original', None) bound_related_object = relation.bind(context['form'], original, bound_related_object_class) context['bound_related_object'] = bound_related_object - t = loader.get_template(bound_related_object.template_name()) + t = loader.select_template(bound_related_object.template_name()) output = t.render(context) context.pop() return output --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---