viewhelpers.formview.formviewmixin — Form view mixins¶
-
class
FormViewMixin¶ Bases:
objectMixin class for form views.
Note
You should import this class with
from django_cradmin import viewhelpers, and refer to it usingviewhelpers.formview.FormViewMixin.-
listing_viewname= 'INDEX'¶ Get the view name for the listing page. You can set this, or implement
get_listing_url(). Defaults todjango_cradmin.crapp.INDEXVIEW_NAME.
-
get_pagetitle()¶ Get the page title (the title tag).
-
get_pageheading()¶ Get the page heading.
Defaults to
get_pagetitle().
-
get_form_renderable()¶ Get a
django_cradmin.renderable.AbstractRenderablethat renders the form.This will typically be a uicontainer — HTML builder with form support tree containing a
django_cradmin.uicontainer.form.Form, but it can be any AbstractRenderable. Not using adjango_cradmin.uicontainer.form.Form(or a subclass of it) is fairly complex when it comes to handling error messages and form rendering, so it is generally not recommended.See
django_cradmin.viewhelpers.formview.formview.WithinRoleFormView()for examples.Returns: The renderable object. Return type: django_cradmin.renderable.AbstractRenderable
-
add_formview_mixin_context_data(context)¶ Must be used by get_context_data() in subclasses to add the context data required to render the view.
Examples
Adding the required context data:
def get_context_data(self, **kwargs): context = super(MyView, self).get_context_data(**kwargs) self.add_formview_mixin_context_data(context=context) return context
-
get_listing_url()¶ Get the URL of the listing view.
Defaults to
listing_viewname. This is used as the success URL by default.
-
get_default_save_success_url()¶ Get the save success URL.
Defaults to
get_listing_url(), but ifsuccess_urlis inrequest.GET, that is used instead.
-
get_success_url()¶ Defaults to
get_default_save_success_url().
-