The following describe the top-level variables Djata provides for the execution
context for a template. These can be used in any Djata template-based view,
like anything that mixes in djata.formats.TemplateFormat, such as any of the
formatters exported by djata.formats.format_html. These include:
RawHtmlFormat(defaults to the.raw.htmlextension)HtmlFormat(defaults to the.htmlextension)
request: the Django HTTPRequestobject.settings: the Django settings module.url: an object representing the current URL, that can be used to render the current URL, or variations of that URL with slightly different query strings.
object
The object will also be aliased with a variable by the same name as the view.
fieldstablefield_names
objectsfilters
The objects will also be aliased with a variable by the same name as the view.
viewsan array of view metadata objects, each constructed fromview.Metafor each view in the relevant views module.
page_numberthe current page numberpage_lengththe number of objects per pagepaginatorthedjango.core.paginator.Paginatorobjectpagethedjango.core.paginator.Pageobjectfixed_page_lengthis boolean and indicates that the paginator is in use.page_groupsis a list of lists. The inner lists are guaranteed to include the first, current, and last page number. The lists also include page numbers from the current page number's "neighborhood" at various orders of magnitude.
You can subclass djata.exceptions.UserError to create custom error pages for
user exceptions. If you create a UserError subclass called FoobarError, by
default the exception will be rendered with the
djata/errors/foobar_error.html template and the HTTP response object will be
HttpResponseBadRequest. These can be overridden with the template and
response_class properties.
In the template context, you can expect the following variables:
title: the error title, like "Foobar error"error: the exception object
If you do not provide a template for your error, Djata will render the generic
djata/errors/base.html template.