[1.8.x] Added each_context() and a template tip to custom admin view docs.
Backport of 648e516b8d
from master
This commit is contained in:
parent
2347f3267f
commit
8277f5d7d0
|
@ -1440,8 +1440,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(request),
|
||||
# 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::
|
||||
|
||||
|
|
Loading…
Reference in New Issue