How can I get the reverse url for a Django Flatpages template

后端 未结 10 1158
情深已故
情深已故 2021-01-31 10:33

How can I get the reverse url for a Django Flatpages template

10条回答
  •  抹茶落季
    2021-01-31 11:09

    When you create any flatpage, you need to specify an URL which is saved as part of the model. Hence you can retrieve the URL from any flatpage object. In a template:

    {{ flatpage.url }}
    

    Remapping flatpage URLs in urls.py and then having to use reverse sort of defeats the purpose of the flatpages app.

提交回复
热议问题