Flask的url_for()方法如何动态生成链接


简单的CRUD链接,编辑链接是 /<post_id>/edit ,删除链接是 /<post_id>/delete ,这样的链接如何创建?

自己目前用 /{{ post.post_id }}/delete/ 这样的方法写在模版里,但维护起来不方便,不知道 url_for() 有没有对应的参数呢?

flask jinja2

vincing 11 years, 10 months ago

url_for('edit', post_id=post.id)
url_for('del', post_id=post.id)

sbthere answered 11 years, 10 months ago

Your Answer