From: Brett Parker Date: Thu, 25 Feb 2010 10:33:54 +0000 (+0000) Subject: Make it so that we don't do anything silly in the context processor by trying X-Git-Url: https://git.sommitrealweird.co.uk/sommitrealweird.git/commitdiff_plain/5f32bb7449977fa78ce14ddfb46bd37c6bcb0737?hp=6a88c21915254742aa127e1871bc0d3c933c12d1 Make it so that we don't do anything silly in the context processor by trying to pull a section name that doesn't exist --- diff --git a/sommitrealweird/blog/context_processors.py b/sommitrealweird/blog/context_processors.py index 9c203cf..9505bb9 100644 --- a/sommitrealweird/blog/context_processors.py +++ b/sommitrealweird/blog/context_processors.py @@ -17,9 +17,14 @@ def content_breadcrumb(request): parts = path.split('/') if parts[0] == "section": - # Just need to add the section title to the breadcrumb - section = BlogSection.objects.get(slug__exact=parts[1]) - breadcrumb.append({'url': section.get_absolute_url(), 'title': section.title}) + # Just need to add the section title to the breadcrumb *if* we + # actually have a section + if len(parts) > 1: + try: + section = BlogSection.objects.get(slug__exact=parts[1]) + breadcrumb.append({'url': section.get_absolute_url(), 'title': section.title}) + except: + pass if len(parts) == 5 and \ parts[0].isdigit() and \