How to enable editing of the home page from the admin interface for mezzanine

Posted by: senex 13 years, 2 months ago

(Comments)

UPDATE

Mezzanine has gone through a lot in 2+ years and has a proper way f supporting the home page now.  Following are the new instructiosn that come with urls.py

    # HOMEPAGE AS AN EDITABLE PAGE IN THE PAGE TREE
    # ---------------------------------------------
    # This pattern gives us a normal ``Page`` object, so that your
    # homepage can be managed via the page tree in the admin. If you
    # use this pattern, you'll need to create a page in the page tree,
    # and specify its URL (in the Meta Data section) as "/", which
    # is the value used below in the ``{"slug": "/"}`` part.
    # 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/"
    # should be used if you want to customize the homepage's template.

Old method

A drawback of using mezzanine is that you cannot edit the home page from the admin interface.  Here are quick instructions of how to change this

1) Create a page and call it "home"

2) edit urls.py and add the following snippet

from mezzanine.pages.views import page

def home_page(request):
    request.path = "/"
    return page(request, "home")

3) Still in urls.py, replace

url("^$", direct_to_template, {"template": ""}, name="home")

with

url("^$", home_page, name="home"),

You should end up with something that looks like the following:

urlpatterns = patterns("",
    ("^admin/", include(admin.site.urls)),
    url("^$", home_page, name="home"),
    ("^", include("mezzanine.urls")),


Currently unrated


Comments

Recent Posts

Archive

2016
2014
2013
2012
2011
2006

Categories

Authors

Feeds

RSS / Atom

Menu