Breadcrumbs support on django class based views
Project description
To enable django-views-breadcrumbs you need add views_breadcrumbs to INSTALLED_APPS:
INSTALLED_APPS += ('views_breadcrumbs',)
To add breadcrumb to view, use breadcrumb decorator:
from views_breadcrumbs.views import breadcrumb ... @breadcrumb('index') class IndexView(View): ... @breadcrumb(lambda args, kwargs, context, request: context['category'].name, parent='project.views.index') class ProductListView(ListView): ...
where project.views.index is view name of parent view.
If you want to pass object (first) function parameters to parent, you should use parent_args. When you pass parent_args, parent view will be not dispatched:
@breadcrumb(lambda args, kwargs, context, request: context['product'].name, parent='project.views.product-list', parent_args=lambda args, kwargs, context, request: [], {}, {'category': context['product'].category} ) class ProductDetailView(DetailView): ...
parent_args must return list of args, kwargs and context, witch will pass to parent breadcrumb object parameter
Settings
Set BREADCRUMBS_TEMPLATE_CONTEXT_NAME to change context name (default is breadcrumbs):
BREADCRUMBS_TEMPLATE_CONTEXT_NAME = 'breadcrumbs'
Middleware
If you want to get warnings when middle view of breadcrumbs branch is dispatched (it means dispatched not only current view, but also parent), you can use BreadcrumbsWarningMiddleware:
MIDDLEWARE_CLASSES += ('views_breadcrumbs.middleware.BreadcrumbsWarningMiddleware', )
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for django-views-breadcrumbs-0.1.dev3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0711455c77b80504aa3106181c02a6cd9a4e70ea40225a69306f2c8ecfe6448e |
|
MD5 | 64b19af42706e2dbe8d5d7a6a19ef6b5 |
|
BLAKE2b-256 | 2015a4bd020a27659a8f8752da506101c1313c7b86f2c2076187adbb0b44f6cd |