django-cms 应用程序挂钩主页错误

发布于 2025-01-02 15:06:48 字数 1232 浏览 2 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挽梦忆笙歌 2025-01-09 15:06:48

这是一个有点狡猾的解决方法,但我今天可以接受它。我基本上将一个名为 /films 的子页面添加到 /home 中,确保它不在导航中,并在那里添加应用程序挂钩。

home/fake-child-page 没有自己的内容,所以这就是为什么我可以忍受它,并且我留下了我想要的网址。

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

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
浅暮の光 2025-01-09 15:06:48

这可能是您的 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文