【发布时间】:2017-11-22 07:59:33
【问题描述】:
如果您在 Django 中有一个保存 slug 的博客模型,您如何从该 slug 字段创建一个 href 链接?
【问题讨论】:
-
在模板中:
<a href="/something/{{post.slug}}/">{{post.title}}</a>在 urls.py 中:url(r'^(?P<slug>[\w-]+)/', views.something, name='post'),
标签: python django django-models slug