diff options
| author | Clifford Gama <cliffygamy@gmail.com> | 2025-02-20 09:44:35 +0200 |
|---|---|---|
| committer | nessita <124304+nessita@users.noreply.github.com> | 2025-04-08 22:02:10 -0300 |
| commit | a2f7b3a6a04c8c46c38040c9d9d5bdc6298bd714 (patch) | |
| tree | 1469d9e8695ffc4e8610f8534afa456d69664868 /docs | |
| parent | f9f0a183273724046710efbb3e6646d9fe3fd08e (diff) | |
Clarified `url` and `name` arguments in flatpages URLconf ref docs.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/contrib/flatpages.txt | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/docs/ref/contrib/flatpages.txt b/docs/ref/contrib/flatpages.txt index 827d14d613..8a2fda3f92 100644 --- a/docs/ref/contrib/flatpages.txt +++ b/docs/ref/contrib/flatpages.txt @@ -89,16 +89,21 @@ to place the pattern at the end of the other urlpatterns:: matched. 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 -tag:: +to hard code their URLs in the :doc:`URLconf </topics/http/urls>`:: from django.contrib.flatpages import views urlpatterns += [ - path("about-us/", views.flatpage, {"url": "/about-us/"}, name="about"), - path("license/", views.flatpage, {"url": "/license/"}, name="license"), + path("about-us/", views.flatpage, kwargs={"url": "/about-us/"}, name="about"), + 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 -------------------- |
