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
ListMixin—default_template_name,tags,permission_shortcode,empty_list_messageSearchMixin—search_param,search_fields,site_searchFilterMixin—filter_fields,filter_form_class,filter_targetPaginationMixin—paginate_by,per_page_options,page_kwarg,per_page_kwarg,pagination_target- Forms and objects
FormMixin—default_template_name,form_attributesObjectMixin— object detail URLs and breadcrumbs (see ObjectMixin)ModelFormMixin— model forms for create/update- List actions and permissions
ListActionMixin— bulk actions from the list action bar (stage 4)ActionMixin— per-object permission checks on delete/update- Templates and model binding
TemplateViewMixin—default_template_nameviadefault_template_nameon concrete viewsModelMixin— resolvesmodelfrom the enclosingModelControllerLogMixin— audit logging whendjmvc_historyis installed
Further topics¶
Optional packages (history, debug, auth) are described in Install djmvc.
- Menus and tags
Tag views with
navigation,object, orlist_action. Usecontroller.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_debugand browse http://localhost:8000/debug/controller/ as superuser.- Internationalization
djmvc ships French translations; wrap user-visible strings in
gettextwhen overriding views (stage 4).