django-cms 应用程序挂钩主页错误
我正在使用 django-cms,我想为现有应用程序创建一个应用程序挂钩。如果我选择显示应用程序挂钩的页面不是主页,这很好。
这是我要挂钩的应用程序的 urls.py:
from django.conf.urls.defaults import patterns, include, url
urlpatterns = patterns('films.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)
我有 url:
/ (<- set to have the slug home, but django-cms doesn't seem to serve it at /home if it's the startpage)
/news
/...
当我将主页设置为具有应用程序挂钩时,它会呈现我的电影的索引。意见,购买我得到一个 404 去任何细节行动。
即,
/ <- correctly renders films.index
/home <- 404
/home/1 <- 404
/1 <- 404
如果我将应用程序挂钩更改为新闻下方,则一切正常(或者如果我将另一个页面设为主页)。
/news <- correctly renders films.index
/news/1 <- correctly renders films.detail
问题似乎是 django-cms 忽略了起始页的 slug,有没有办法解决这个问题?
我可能应该提到,我已经尝试设置覆盖 url 来解决这个问题,虽然随后提供了 /home,但 /home/1 仍然给出了 404。
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'^
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.
, 'index'),
url(r'^(?P<film_id>\d+)/
The cms_app.py is as follows:
I have the urls:
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
If I change the app-hook to be under news instead, everything works fine, (or if I make another page the home page).
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.
, 'detail'),
)
The cms_app.py is as follows:
I have the urls:
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
If I change the app-hook to be under news instead, everything works fine, (or if I make another page the home page).
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个有点狡猾的解决方法,但我今天可以接受它。我基本上将一个名为 /films 的子页面添加到 /home 中,确保它不在导航中,并在那里添加应用程序挂钩。
home/fake-child-page 没有自己的内容,所以这就是为什么我可以忍受它,并且我留下了我想要的网址。
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.
这可能是您的 django-cms 版本的错误:
https://github.com/ divio/django-cms/issues/47
This might be a bug with your version of django-cms:
https://github.com/divio/django-cms/issues/47