Skip to content
Easy to use generic breadcrumbs system for Django framework.
Python HTML Shell
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


django-breadcrumbs is a breadcrumb system to Django framework that allow you to add custom breadcrumbs for simple views, generic views and support Django FlatPages app.

In format of a pluggable middleware that add a breadcrumbs callable/iterable in your request object, allowing you to set breadcrumbs (one or more) in each view accepting objects, lists or tuples added from request.breadcrumbs and is iterable, easy to use in templates providing a object with name and url attributes.

Note: For Django 1.x, check for tag 1.0 and patches :)

1 - Install django-breadcrumbs

Add breadcrumbs.middleware.BreadcrumbsMiddleware to your MIDDLEWARE_CLASSES and breadcrumbs to your INSTALLED_APPS.

The middleware store breadcrumbs in request, and the app is needed to enable Django signals in breadcrumbs app.

Also, if you did't put request context processor on yours TEMPLATE_CONTEXT_PROCESSORS, add it, ex:


2 - Adding breadcrumbs

To add breadcrumbs you just need to call request.breadcrumbs('Title',url), ex:

def about(request):

def generic_crud_view(request,model,action):
    model = model name
    action = action name

        (_(model.title()),'/crud/%s' % model),
        (_('%s %s') % (action.title(),model.title()),'/crud/%s/%s' % (model,action)),


All modes of add a breadcrumb:

# one by one
request.breadcrumbs( name, url )

# various tuples/lists
request.breadcrumbs( ( (name1, url1), (name2, url2), (name3, url3), ...,) )
request.breadcrumbs( [ [name1, url1], [name2, url2], [name3, url3], ...] )

# objects with attributes name and url in list / tuple format:
request.breadcrumbs( ( obj1, obj2, obj3, obj4, ......) )
request.breadcrumbs( [ obj1, obj2, obj3, obj4, ......] )

Note: You can use request.breadcrumbs safely in any middleware after BreadcrumbsMiddleware or any place where you have request object after BreadcrumbsMiddleware are processed

3 - Enable FlatPages + Breadcrumbs

FlatPages is a app that allow user create urls with static content and a title. But create breadcrumbs for this kind of 'unknow' url path isn't fun at all, so I modified FlatpageFallbackMiddleware to fill breadcrumbs for each flat page in path.

Is really easy to use, just add breadcrumbs.middleware.FlatpageFallbackMiddleware in your MIDDLEWARE_CLASSES after BreadcrumbsMiddleware and remove Django FlatpageFallbackMiddleware. Now you flat pages will be in breadcrumbs too.

FlatpageFallbackMiddleware will call breadcrumbs.views.flatpage, that as bonus, cache results of FlatPage models, avoiding DB in every request, and in every part of breadcrumb.

Flatpages in

Django also supports Flatpages in, as doc in show. To use this way, do something like:

urlpatterns = patterns('',
    (r'^pages/', include('breadcrumbs.urls')),

urlpatterns += patterns('breadcrumbs.views',
    (r'^pages2/(?P<url>.*)$', 'flatpage'),

urlpatterns += patterns('breadcrumbs.views',
    url(r'^license/$', 'flatpage', {'url': '/flat04/'}, name='license'),

4 - Using in templates

To use breadcrumbs in template, only that you need is iterate over breadcrumbs, example:

{% for breadcrumb in request.breadcrumbs %}
<a href="{{ breadcrumb.url }}">{{ }}</a>{% if not forloop.last %} &raquo; {% endif %}
{% endfor %}

5 - Options

django-breadcrumbs have a single option to set in your

BREADCRUMBS_AUTO_HOME: defaults to False, If True, breadcrumbs add as first Breadcrumb in list (_("Home"),u"/")
BREADCRUMBS_HOME_TITLE: defaults to _(u'Home')
Something went wrong with that request. Please try again.