将自定义应用程序与 django-cms 集成时,URL 不起作用

发布于 2024-10-20 18:41:26 字数 483 浏览 5 评论 0原文

我正在尝试将 django 应用程序与 django-cms 集成。我正在使用基本 Django 教程中提到的基本“投票”应用程序,并遵循 此处

现在我可以集成该应用程序并可以查看“投票”页面。但是,当我按“提交”时,django-cms 会给出错误

“CMS:找不到“polls/1/vote”页面

更新:如果我将以下行添加到主 urls.py,则所有内容工作正常,

(r'^polls/', include('polls.urls')),

但在 django 和 django-cms 中通常不鼓励这样做,有办法吗?

I'm trying to integrate an django application with django-cms. I'm using the basic "Poll" application as mentioned in basic Django tutorial and following guidelines over here.

Now I can integrate the application and can view the "poll" page. But when I press 'submit', the django-cms gives me error

"CMS: Page not found for "polls/1/vote"

Update: If I add following line to main urls.py, everything works fine.

(r'^polls/', include('polls.urls')),

But this is usually discouraged in django and django-cms. Is there a way out?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

玩套路吗 2024-10-27 18:41:26

您需要做的是为您的民意调查应用程序创建一个 apphook 并在其中包含 url。看一下: http: //docs.django-cms.org/en/2.1.3/extending_cms/extending_examples.html#my-first-app-apphook

编辑

请记住在附加后重新启动服务器应用挂钩。

What you need to do is create an apphook for your polls application and include the urls there. Have a look at: http://docs.django-cms.org/en/2.1.3/extending_cms/extending_examples.html#my-first-app-apphook

EDIT

Remember to restart the server once you attach the apphook.

橙味迷妹 2024-10-27 18:41:26

呃,我明白了。应用程序模板内的硬编码 URL 不起作用。人们应该在模板中使用 {% url %} 标签。

Uh, I figured it out. Well the hard-coded URLs inside the app templates do not work. One should use {% url %} tags inside the templates.

初见 2024-10-27 18:41:26

使用 apphooks 是解决方案,但是如果您将 cms url 路由放在最后(urlpatterns 的末尾),它就会起作用。尝试一下

Using apphooks would be the solution, however It works if you put the cms url route at last, at the end of the urlpatterns. Try that

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