Andrew Barrett
Andrew Barrett

Reputation: 19911

django-cms app hook at homepage error

I'm playing with django-cms and I want to create an app-hook to an existing application. This is fine if the page I choose to show the app-hook is not the homepage.

This is my urls.py for my application that I'm hooking in:

from django.conf.urls.defaults import patterns, include, url

urlpatterns = patterns('films.views',
    url(r'^$', 'index'),
    url(r'^(?P<film_id>\d+)/$', 'detail'),
)

The cms_app.py is as follows:

from cms.app_base import CMSApp
from cms.apphook_pool import apphook_pool
from django.utils.translation import ugettext_lazy as _

class FilmApphook(CMSApp):
    name = _("Film Apphook")
    urls = ["films.urls"]

apphook_pool.register(FilmApphook)

I have the urls:

/ (<- set to have the slug home, but django-cms doesn't seem to serve it at /home if it's the startpage)
/news
/...

When I set the home page to have the app-hook, it renders the index of my films.views, buy I get a 404 going to any detail actions.

I.e

/ <- correctly renders films.index
/home <- 404
/home/1 <- 404
/1 <- 404

If I change the app-hook to be under news instead, everything works fine, (or if I make another page the home page).

/news <- correctly renders films.index
/news/1 <- correctly renders films.detail

The problem seems to be that django-cms ignores the slug for the start-page, is there anyway to work around this?

I should probably mention that I've tried to set the overwrite url to work round this, and while /home is then served, /home/1 still gives a 404.

Upvotes: 0

Views: 1027

Answers (2)

Timmy O&#39;Mahony
Timmy O&#39;Mahony

Reputation: 53981

This might be a bug with your version of django-cms:

https://github.com/divio/django-cms/issues/47

Upvotes: 0

Andrew Barrett
Andrew Barrett

Reputation: 19911

It's a bit of a dodgy workaround, but I can live with it for today. I basically add a child page to /home named /films, making sure it's not in navigation, and add the app-hook there as well.

The home/fake-child-page have no content of their own, so that's why I can live with it, and I'm left with the urls I want.

/ <- films.views.index
/films/1 <- films.views.details/1

Upvotes: 1

Related Questions