djblets.configforms.views¶
Standard views for displaying and interacting with configuration forms.
- class ConfigPagesView(**kwargs)¶
Bases:
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
andpage_classes
, at a minimum.To dynamically compute pages, implement a
page_classes
method and decorate it with@property
.- title = None¶
The page title.
The title to display over the navigation sidebar.
- pages_id = 'config_pages'¶
The element ID for the page’s container.
- template_name = 'configforms/config.html'¶
The template used to render the view.
- base_template_name = 'base.html'¶
The base template that the default template should inherit from.
- page_classes = []¶
The list of page subclasses to display.
- css_bundle_names = []¶
The list of CSS bundle names to include on the page.
- js_bundle_names = []¶
The list of JavaScript bundle names to include on the page.
- js_model_class = None¶
The optional Backbone model used for the view state.
- js_view_class = 'Djblets.Config.PagesView'¶
The Backbone view used to render the main view.
- http_method_names = ['get', 'post']¶
The HTTP methods that this view will respond to.
- render_sidebar = True¶
Whether or not to render the sidebar.
- dispatch(request, *args, **kwargs)¶
- post(request, *args, **kwargs)¶
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)¶
Return extra context data to render in the template.
- Returns:
A dictionary of context data for the page.
- Return type:
- get_js_view_data()¶
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:
- get_js_model_data()¶
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: