]> git.sommitrealweird.co.uk Git - sommitrealweird.git/blobdiff - sommitrealweird/blog/context_processors.py
Update to work with newer django and python3
[sommitrealweird.git] / sommitrealweird / blog / context_processors.py
index 9c203cfcf3103103159eace676a744493c2e9603..97fe9acefc17dc935d708edbdae116882759c7ca 100644 (file)
@@ -1,5 +1,5 @@
 from django.conf import settings
-from blog.models import BlogEntry, BlogSection
+from sommitrealweird.blog.models import BlogEntry, BlogSection
 import re
 
 def blog_feed(request):
@@ -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 \