mirror of
https://github.com/django/django.git
synced 2025-05-21 14:26:29 +00:00
[5.2.x] Clarified url
and name
arguments in flatpages URLconf ref docs.
Backport of a2f7b3a6a04c8c46c38040c9d9d5bdc6298bd714 from main.
This commit is contained in:
parent
4d89d8c180
commit
0ba34e7ca0
@ -89,16 +89,21 @@ to place the pattern at the end of the other urlpatterns::
|
|||||||
matched.
|
matched.
|
||||||
|
|
||||||
Another common setup is to use flat pages for a limited set of known pages and
|
Another common setup is to use flat pages for a limited set of known pages and
|
||||||
to hard code the urls, so you can reference them with the :ttag:`url` template
|
to hard code their URLs in the :doc:`URLconf </topics/http/urls>`::
|
||||||
tag::
|
|
||||||
|
|
||||||
from django.contrib.flatpages import views
|
from django.contrib.flatpages import views
|
||||||
|
|
||||||
urlpatterns += [
|
urlpatterns += [
|
||||||
path("about-us/", views.flatpage, {"url": "/about-us/"}, name="about"),
|
path("about-us/", views.flatpage, kwargs={"url": "/about-us/"}, name="about"),
|
||||||
path("license/", views.flatpage, {"url": "/license/"}, name="license"),
|
path("license/", views.flatpage, kwargs={"url": "/license/"}, name="license"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
The ``kwargs`` argument sets the ``url`` value used for the ``FlatPage`` model
|
||||||
|
lookup in the flatpage view.
|
||||||
|
|
||||||
|
The ``name`` argument allows the URL to be reversed in templates, for example
|
||||||
|
using the :ttag:`url` template tag.
|
||||||
|
|
||||||
Using the middleware
|
Using the middleware
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user