Getting Django admin url for an object

前端 未结 9 1698
有刺的猬
有刺的猬 2020-12-02 03:51

Before Django 1.0 there was an easy way to get the admin url of an object, and I had written a small filter that I\'d use like this:

9条回答
  •  庸人自扰
    2020-12-02 04:24

    You can use the URL resolver directly in a template, there's no need to write your own filter. E.g.

    {% url 'admin:index' %}

    {% url 'admin:polls_choice_add' %}

    {% url 'admin:polls_choice_change' choice.id %}

    {% url 'admin:polls_choice_changelist' %}

    Ref: Documentation

提交回复
热议问题