Jump to >

djblets.configforms.views

Standard views for displaying and interacting with configuration forms.

class ConfigPagesView(**kwargs)[source]

Bases: django.views.generic.base.TemplateView

Base view for a set of configuration pages.

This will render the page for managing a set of configuration sub-pages (djblets.configforms.pages.ConfigPage subclasses).

Subclasses are expected to provide title and page_classes, at a minimum.

To dynamically compute pages, implement a page_classes method and decorate it with @property.

title = None[source]

The page title.

nav_title = None[source]

The title to display over the navigation sidebar.

pages_id = u'config_pages'[source]

The element ID for the page’s container.

template_name = u'configforms/config.html'[source]

The template used to render the view.

base_template_name = u'base.html'[source]

The base template that the default template should inherit from.

page_classes = [][source]

The list of page subclasses to display.

css_bundle_names = [][source]

The list of CSS bundle names to include on the page.

js_bundle_names = [][source]

The list of JavaScript bundle names to include on the page.

js_model_class = None[source]

The optional Backbone model used for the view state.

js_view_class = u'Djblets.Config.PagesView'[source]

The Backbone view used to render the main view.

http_method_names = [u'get', u'post'][source]

The HTTP methods that this view will respond to.

render_sidebar = True[source]

Whether or not to render the sidebar.

dispatch(*args, **kwargs)[source]
post(request, *args, **kwargs)[source]

Handle HTTP post requests to the view.

This will instantiate the form that the POST was targeting, validate the form, and then trigger its save if valid, reloading the page with the new state.

Parameters:request (HttpRequest) – The HTTP request from the client.
Returns:Either a redirect (if successfully posted), or a standard response with the page content.
Return type:HttpResponse
get_context_data(**kwargs)[source]

Return extra context data to render in the template.

Returns:A dictionary of context data for the page.
Return type:dict
get_js_view_data()[source]

Return custom options to pass to the JavaScript view.

By default, this will return an empty dictionary. Subclasses can override to provide custom data.

Returns:A dictionary of options to pass to the View instance. By default, this will be empty.
Return type:dict
get_js_model_data()[source]

Return custom attributes to pass to the JavaScript model.

If js_model_class is provided, the data returned from this function will be provided to the model when constructued.

By default, this will return an empty dictionary. Subclasses can override to provide custom data.

Returns:A dictionary of attributes to pass to the Model instance. By default, this will be empty.
Return type:dict