Commit 648e516b authored by Joe Simpson's avatar Joe Simpson Committed by Tim Graham
Browse files

Added each_context() and a template tip to custom admin view docs.

parent 002425fe
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -1406,8 +1406,23 @@ templates used by the :class:`ModelAdmin` views:
                return my_urls + urls

            def my_view(self, request):
                # custom view which should return an HttpResponse
                pass
                # ...
                context = dict(
                   # Include common variables for rendering the admin template.
                   self.each_context(),
                   # Anything else you want in the context...
                   key=value,
                )
                return TemplateResponse(request, "sometemplate.html", context)

    If you want to use the admin layout, extend from ``admin/base_site.html``:

    .. code-block:: html+django

       {% extends "admin/base_site.html" %}
       {% block content %}
       ...
       {% endblock %}

    .. note::