django-breadcrumbs

Easy to use generic breadcrumbs system for Django framework
Download

django-breadcrumbs Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Publisher Name:
  • Felipe Prenholato
  • Publisher web site:
  • http://github.com/chronossc/

django-breadcrumbs Tags


django-breadcrumbs Description

Easy to use generic breadcrumbs system for Django framework django-breadcrumbs is a breadcrumb system for the Django framework, which allows 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.Install django-breadcrumbsJust put in your python patch and add breadcrumbs.middleware.BreadcrumbsMiddleware to your MIDDLEWARE_CLASSES.Adding breadcrumbsTo add breadcrumbs you just need to call request.breadcrumbs('Title',url), ex:def about(request): request.breadcrumbs(_("About"),request.path_info) ...def generic_crud_view(request,model,action): """ model = model name action = action name """ request.breadcrumbs() ...All modes of add a breadcrumb:# one by onerequest.breadcrumbs( name, url )# various tuples/listsrequest.breadcrumbs( ( (name1, url1), (name2, url2), (name3, url3), ...,) )request.breadcrumbs( , , , ...] )# objects with attributes name and url in list / tuple format:request.breadcrumbs( ( obj1, obj2, obj3, obj4, ......) )request.breadcrumbs( )Note: You can use request.breadcrumbs safely in any middleware after BreadcrumbsMiddleware or any place where you have request object after BreadcrumbsMiddleware are processedEnable FlatPages + BreadcrumbsFlatPages 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 all done!Using in templatesTo use breadcrumbs in template, only that you need is iterate over breadcrumbs, example:{% for breadcrumb in request.breadcrumbs %}< a href="{{ breadcrumb.url }}" >{{ breadcrumb.name }}< /a >{% if not forloop.last %} >> {% endif %}{% endfor %}Optionsdjango-breadcrumbs have a single option to set in your settings.py:BREADCRUMBS_AUTO_HOME: defaults to False, If True, breadcrumbs add as first Breadcrumb in list (_("Home"),u"/") Requirements: · Python · Django


django-breadcrumbs Related Software