Package: autobreadcrumbs
IntroductionAutoBreadcrumbsis a Django application to automatically build a breadcrumb in your website like
this :Home > Some page > Some child pageEachcrumbdisplays a title with a link to represent a view, the crumb tree is determined from the urls map
of your project, their titles and links are determined from the associated view entries in the breadcrumbs
registry.RequiresSince the0.9version, it requires at least Django 1.5, for Django 1.4 you
will have to use the0.8.1.1, you can find him in the github releases.LinksDownload hisPyPi package;Clone it on hisGithub repository;InstallIn yoursettingsfile addAutoBreadcrumbsto your installed apps :INSTALLED_APPS = (
    ...
    'autobreadcrumbs',
    ...
)Import default settings:from autobreadcrumbs.settings import *Then register hiscontext processor:TEMPLATE_CONTEXT_PROCESSORS = (
    ...
    'autobreadcrumbs.context_processors.AutoBreadcrumbsContext',
    ...
)And finally, as for theautodiscoverfor the admin site
(django.contrib.admin), you will have to add these two lines in yoururls.pyproject :import autobreadcrumbs
autobreadcrumbs.autodiscover()This is optional but if you don’t do this, allcrumbs.pyfile will be
ignored and only titles defined insettings.AUTOBREADCRUMBS_TITLESwill be used.UsageNote that this app will don’t work correctly if you don’t have a strong organisation in your
urls map.You must ensure that all your urls are correctly named (seeNaming URL patterns);Different views must not use the same url;If you use url namespace, prefix all your crumb url name with it;Regroup your restricted views on some url paths and don’t mix them with non-restricted view urls.View registrationRegistrationThecontext processormakes a search from the current url that is splitted in segments which represent
the crumbs. For each segment, an entry is searched on his URL name in the breadcrumbs registry in this
step order :If the name has an entry insettings.AUTOBREADCRUMBS_TITLES, then use it;If the name has an entry in acrumbs.pyfile in one of your apps, then use it;If none of these steps succeeds to find the URL name, the ressource will be ignored and not be displayed
in the breadcrumbs.If you need tohidea ressource from breadcrumbs, just set his URL name to aNonevalue, this will act in
ignoring the ressource.A crumb title value use the Django template system to be rendered and is aware of the context of the template
where it is called, so you can use all available template filters, tags and variables in your crumb titles.Optionally a crumb entry can be a tuple containing the title and callable
function :'documents-private-doc': (ugettext_lazy('Sitemap'), lambda x,y: True),The callable function is given two arguments, the url name and the Request
object. The callable must return a boolean,Trueif the crumb can be
displayed orFalseif the crumb must be ignored.This form is generally used to check permission for private views, like this :def check_crumb_perm(name, request):
    if name == 'documents-private-doc' and request.user.is_anonymous():
        return False
    return True

AUTOBREADCRUMBS_TITLES = {
    ...
    'documents-private-doc': (ugettext_lazy('Sitemap'), lambda x,y: True),
    ...
}App crumbsApplications should define their crumbs in acrumbs.pyfile like this :from autobreadcrumbs import site
from django.utils.translation import ugettext_lazy

site.update({
    ...
    'documents-index': ugettext_lazy('Sitemap'),
    ...
})Note the usage ofugettext_lazyto get translated strings, if you don’t use theDjango internationalization systemin your
project you can avoid it, but if you plan to use it you must applyugettext_lazyon your title strings.Project crumbsAlso you can register crumbs in your project settings :AUTOBREADCRUMBS_TITLES = {
    "pages-index1": u"My index",
    "pages-index2": u"My index alternative",
}Crumbs setted in project settings have the higher priority on application crumbs. As forApp crumbsyou should useugettext_lazyon your title strings.Crumbs with URL namespaceIf you use URL namespace on some views, remember to prefixed their crumb’s url name with the namespace followed by a colon character, like this :AUTOBREADCRUMBS_TITLES = {
    ...
    "mynamespace:pages-index1": u"My index",
    ...
}If you forget to do this, your crumb won’t be finded or be filled with a wrong crumb (from an another app view with the same url name but without the namespace).Template contextIn all your templates laying that have the global context, two additional variables (autobreadcrumbs_elementsandautobreadcrumbs_current) will be added by thecontext processor.autobreadcrumbs_elementsThis variable will contain the breadcrumb as a list of crumbs in the correct order, where each crumb will be
aBreadcrumbRessourceinstance. ABreadcrumbRessourceinstance contains the following attributes :path: relative path to the ressource URL;name: the ressource name (that is the name of the URL linked to the ressource), prefixed with the namespace if any;title: the ressource title to be displayed;view_args: argument list given to the ressource view;view_kwargs: named argument list given to the ressource view;autobreadcrumbs_currentThis variable will contains theBreadcrumbRessourceinstance of the current crumb, this instance is the same as
the last list item in theautobreadcrumbs_elements.Template tagsThese tags are avalaible after loading their library in your templates :{% load autobreadcrumb %}current_title_from_breadcrumbsThis simply returns the title from the current ressource.autobreadcrumbs_tagBuilds the breadcrumb HTML using theautobreadcrumbs_tag.htmltemplate.autobreadcrumbs_linksBuilds the breadcrumb HTML using the template strings insettings.AUTOBREADCRUMBS_HTML_LINKandsettings.AUTOBREADCRUMBS_HTML_SEPARATOR.currentwalkthroughtoReturns the content tag if the current ressource walk through the given ressource URL name.Example :{% currentwalkthroughto 'index' %}This pas walk through the named url 'index'{% endcurrentwalkthroughto %}If the test fail, the tag return an empty string.