Stage 5 — View mixins

djmvc builds each generic view from mixins — small classes that add one concern (filtering, pagination, tables, forms, …). Override mixin attributes on a cloned view or subclass; templates read them from the view object in context.

See ../reference/mixins for every mixin and overridable attribute. Generic views that combine them are listed under Generic views.

For screenshots of list, filter, pagination, and object-menu mixins in action, see Stage 3 — Override default views.

List display

ListMixindefault_template_name, tags, permission_shortcode, empty_list_message

SearchMixinsearch_param, search_fields, site_search

FilterMixinfilter_fields, filter_form_class, filter_target

PaginationMixinpaginate_by, per_page_options, page_kwarg, per_page_kwarg, pagination_target

Tables2Mixintable_template, table_fields

Forms and objects

FormMixindefault_template_name, form_attributes

ObjectMixin — object detail URLs and breadcrumbs (see ObjectMixin)

ModelFormMixin — model forms for create/update

DeleteMixindefault_template_name, icon, color

List actions and permissions

ListActionMixin — bulk actions from the list action bar (stage 4)

ActionMixin — per-object permission checks on delete/update

ViewMixinpermission_shortcode

Templates and model binding

TemplateViewMixindefault_template_name via default_template_name on concrete views

ModelMixin — resolves model from the enclosing ModelController

LogMixin — audit logging when djmvc_history is installed

Further topics

Optional packages (history, debug, auth) are described in Install djmvc.

Menus and tags

Tag views with navigation, object, or list_action. Use controller.get_tagged_views('object', request=request, object=obj) in templates.

Runtime route changes

After site.build(), swap or remove routes on the live registry (site.routes['list'] = , del site.routes['delete']).

Routing debug

Add djmvc_debug and browse http://localhost:8000/debug/controller/ as superuser.

Internationalization

djmvc ships French translations; wrap user-visible strings in gettext when overriding views (stage 4).