Wagtail模型的自定义URL [英] Custom URL for Wagtail model
本文介绍了Wagtail模型的自定义URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个这样的模式:
from wagtail.wagtailcore.models import Page
class Blog(Page):
created = models.DateTimeField(auto_now_add=True)
...
..
现在,我的默认,如果我的s子是 hi-there
,博客文章可以在 site_url:/ hi-there /
但是我想通过网站访问:url / 2014/02/05 / hi-there /
页面有各种各样的方法,如 url,url_path
应该覆盖哪一个,在wagtail中实现这样的最佳做法是什么?
Right Now, my default, if my slug is hi-there
, the blog post is accessible on site_url:/hi-there/
but I want it accessible via site:url/2014/02/05/hi-there/
The page has various methods like url, url_path
which one should I override and what's the best practice to achieve something like this in wagtail?
推荐答案
Wagtail v0.5中的新功能是直接解决这种事情的一种机制:
New in Wagtail v0.5 is a mechanism that directly addresses this sort of thing:
(文档甚至有一个博客示例!)
(the docs even have an Blog example!)
这篇关于Wagtail模型的自定义URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文