Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-views-breadcrumbs, version 0.1.dev3
Filename, size & hash File type Python version Upload date
django-views-breadcrumbs-0.1.dev3.tar.gz (4.8 kB) View hashes Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page