#12292: render_to_response method on AdminSite and ModelAdmin
----------------------------------+-----------------------------------------
Reporter: LeafStorm | Owner: nobody
Status: new | Milestone:
Component: django.contrib.admin | Version: SVN
Keywords: | Stage: Unreviewed
Has_patch: 1 |
----------------------------------+-----------------------------------------
I have written a patch against trunk to add a {{{render_to_response}}}
method to {{{AdminSite}}} and {{{ModelAdmin}}}. The method replaces the
{{{
context_instance = template.RequestContext(request, current_app=self.name)
return render_to_response(templates, context,
context_instance=context_instance)
}}}
idiom at the end of admin views with:
{{{
return self.render_to_response(request, templates, context)
}}}
This may seem like a small change, but it allows the method in which admin
templates are rendered to be overridden. This can be used to inject extra
values into the context for customized templates, or to possibly replace
the Django template language with an external template language like
Jinja2 or Mako in the admin ("loose coupling"). It also reduces the
boilerplate in the admin and makes it easier to upgrade in the event that
the template API changes ("don't repeat yourself").
The included patch includes documentation updates, but no code outside the
admin has been changed (so the rest of the trunk may need updating to use
the new method). All admin-related tests have been run on the patch, and
it is very unlikely to break backwards compatibility, due to the fact that
it merely places the code that was used before in another place.
--
Ticket URL: <http://code.djangoproject.com/ticket/12292>
Django <http://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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.