The horizon.views ModuleΒΆ

class horizon.views.APIView(**kwargs)[source]

Bases: horizon.views.HorizonTemplateView

A quick class-based view for putting API data into a template.

Subclasses must define one method, get_data, and a template name via the template_name attribute on the class.

Errors within the get_data function are automatically caught by the horizon.exceptions.handle() error handler if not otherwise caught.

get(request, *args, **kwargs)[source]
get_data(request, context, *args, **kwargs)[source]

This method should handle any necessary API calls, update the context object, and return the context object at the end.

class horizon.views.HorizonFormView(**kwargs)[source]

Bases: horizon.views.PageTitleMixin, django.views.generic.edit.FormView

class horizon.views.HorizonTemplateView(**kwargs)[source]

Bases: horizon.views.PageTitleMixin, django.views.generic.base.TemplateView

class horizon.views.PageTitleMixin[source]

Bases: object

A mixin that renders out a page title into a view.

Many views in horizon have a page title that would ordinarily be defined and passed through in get_context_data function, this often leads to a lot of duplicated work in each view.

This mixin standardises the process of defining a page title, letting views simply define a variable that is rendered into the context for them.

There are cases when page title in a view may also display some context data, for that purpose the page_title variable supports the django templating language and will be rendered using the context defined by the views get_context_data.

page_title = ''
render_context_with_title(context)[source]

This function takes in a context dict and uses it to render the page_title variable, it then appends this title to the context using the ‘page_title’ key. If there is already a page_title key defined in context received then this function will do nothing.

render_to_response(context)[source]

This is an override of the default render_to_response function that exists in the django generic views, this is here to inject the page title into the context before the main template is rendered.

horizon.views.user_home(request)[source]

Reversible named view to direct a user to the appropriate homepage.

Previous topic

The horizon.context_processors Module

Next topic

The horizon Module

Project Source

This Page