Stephen McDonald committed 2f34d3b

Added handling for slug-based template when the homepage is a page object.

  • Participants
  • Parent commits 23c01d2

Comments (0)

Files changed (3)


+{% extends "pages/richtextpage.html" %}
+{% block main %}
+This template is provided as a custom template for the homepage, for
+when it is configured as an editable page in the navigation tree. Feel
+free to modify it.
+{{ block.super }}
+{% endblock %}


                 error = ("The page processor %s returned %s but must return "
                          "HttpResponse or dict." % (name, type(response)))
                 raise ValueError(error)
-    templates = [u"pages/%s.html" % unicode(slug)]
+    # Check for a template name matching the page's slug. If the homepage
+    # is configured as a page instance, the template "pages/index.html" is
+    # used, since the slug "/" won't match a template name.
+    templates = [u"pages/%s.html" % unicode(slug) if slug != "/" else "index"]
+    # Check for a template matching the page's content model.
     if page.content_model is not None:
         templates.append(u"pages/%s.html" % page.content_model)


     # is the value used below in the ``{"slug": "/"}`` part. Make
     # sure to uncheck "show in navigation" when you create the page,
     # since the link to the homepage is always hard-coded into all the
-    # page menus that display navigation on the site.
+    # page menus that display navigation on the site. Also note that
+    # the normal rule of adding a custom template per page with the
+    # template name using the page's slug doesn't apply here, since
+    # we can't have a template called "/.html" - so for this case, the
+    # template "pages/index.html" can be used.
     # url("^$", "", {"slug": "/"}, name="home"),