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

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

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

10条回答
  •  攒了一身酷
    2021-01-31 10:57

    proper Django>= 1.10:

    urls.py

    urlpatterns += [
        url(r'^(?P.*/)$', flatpage, name='flatpage'),
    ]
    

    easy lookup inside the template:

    {% url "flatpage" url="SOME_URL" %}
    

    where SOME_URL is the value frome the flatpage.url field

提交回复
热议问题