django-cms应用程序钩在主页错误 [英] django-cms app hook at homepage error
问题描述
这是我正在挂钩的应用程序的urls.py:
from django.conf.urls.defaults import patterns,include,url
urlpatterns = patterns 'film.views',
url(r'^ $','index'),
url(r'^(?P< film_id> \d +)/ $','detail' ,
)
cms_app.py如下:
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 )
我有网址:
/(< - 设置为slug home,但django-cms似乎没有在/ home服务,如果它是startpage)
/ news
/ ...
当我设置主页有app-hook时,它渲染我的电影的索引,购买我得到一个404去任何细节的操作。
是的
/< - 正确呈现film.index
/ home< - 404
/ home / 1< - 404
/ 1< - 404
如果我将应用程序钩子更改为新闻,那么一切都可以正常运行(或者如果我将另一个页面设置为主页)
/ news< - 正确呈现film.index
/ news / 1& - 正确呈现电影。细节
问题似乎是django-cms忽略了起始页的lug,,是不是反正要解决这个问题吗?
我应该提到我已经设法覆盖网址来工作,而/ home然后被送达,/ home / 1仍然给了一个404。
这是一个狡猾的解决方法,但我可以e今天。我基本上添加一个子页面到/ home命名/电影,确保它没有在导航,并添加应用程序钩在那里。
家/孩子页面没有自己的内容,所以这就是为什么我可以与它一起生活,我留下了我想要的URL。
/< - films.views.index
/ movies / 1< - films.views.details / 1
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.
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
这篇关于django-cms应用程序钩在主页错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!