Django: How to get the root path of a site in template?

前端 未结 5 1152
春和景丽
春和景丽 2020-12-29 11:24

I want to design a go back home button for my site and how can I get the root path of my site in the template so I can do something like this:



        
5条回答
  •  遥遥无期
    2020-12-29 12:08

    Referring to standard Django example:

    urlpatterns = [
        path('', views.index, name='index'),
    ]
    

    Then template code:

    href="{% url 'index' %}"
    

    will also work.

提交回复
热议问题