1

在按照文档实现RouteablePage 之后,我创建了一个页面,然后尝试渲染它。那是我得到错误的时候。经过一番挖掘,它看起来像是从 wagtailcore/urls.py 开始的,问题是对 serve() 的调用位于 wagtailcore/views.py 中,与此处定义的 RoutablePage serve 函数不匹配。这是我的代码:

class OfficeRoutes(RoutablePageMixin):

    @route(r'^offices/(?P<office_id>[\w-]+)/$', name="offices")
    def office_landing_view(self, request, office_id, *args, **kwargs):
        return HttpResponse("this isn't working")


class OfficePage(RoutablePageMixin, Page):
    body = RichTextField(blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('body', classname="full")
    ]

可能是什么问题?我有一种强烈的感觉,我错过了一些关于如何使用 RoutablePages 的概念。@route 函数的返回主要是猜测。

任何帮助表示赞赏!谢谢!

4

0 回答 0