viewhelpers.formview.formviewmixin — Form view mixins

class FormViewMixin

Bases: object

Mixin class for form views.


You should import this class with from django_cradmin import viewhelpers, and refer to it using viewhelpers.formview.FormViewMixin.

listing_viewname = 'INDEX'

Get the view name for the listing page. You can set this, or implement get_listing_url(). Defaults to django_cradmin.crapp.INDEXVIEW_NAME.


Get the page title (the title tag).


Get the page heading.

Defaults to get_pagetitle().


Get a django_cradmin.renderable.AbstractRenderable that 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 a django_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

Must be used by get_context_data() in subclasses to add the context data required to render the view.


Adding the required context data:

def get_context_data(self, **kwargs):
    context = super(MyView, self).get_context_data(**kwargs)
    return context

Get the URL of the listing view.

Defaults to listing_viewname. This is used as the success URL by default.


Get the save success URL.

Defaults to get_listing_url(), but if success_url is in request.GET, that is used instead.


Defaults to get_default_save_success_url().