Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add BREADCRUMBS_HOME_URL_NAME variable #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,5 @@ django-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"/")
BREADCRUMBS_HOME_TITLE: defaults to _(u'Home')
BREADCRUMBS_HOME_URL_NAME: If set, reverse of this variable will be used for home page url.

7 changes: 6 additions & 1 deletion breadcrumbs/breadcrumbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""

from django.conf import settings
from django.core.urlresolvers import reverse
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext as _
try:
Expand Down Expand Up @@ -72,6 +73,7 @@ class or with get_breadcrumbs().
"""
__bds = []
__autohome = getattr(settings, 'BREADCRUMBS_AUTO_HOME', False)
__home_url_name = getattr(settings, 'BREADCRUMBS_HOME_URL_NAME', None)
__urls = []
__started = False

Expand All @@ -84,7 +86,10 @@ def __fill_home(self):
# fill home if settings.BREADCRUMBS_AUTO_HOME is True
if self.__autohome and len(self.__bds) == 0:
home_title = getattr(settings, 'BREADCRUMBS_HOME_TITLE', _(u'Home'))
self.__fill_bds((home_title, u"/"))
if self.__home_url_name:
self.__fill_bds((home_title, reverse(self.__home_url_name)))
else:
self.__fill_bds((home_title, u"/"))

def _clean(self):
self.__bds = []
Expand Down