conf.urls.url()

url(regex, view, kwargs=None, name=None) [source]

urlpatterns should be a list of url() instances. For example:

1
2
3
4
5
6
7
from django.conf.urls import include, url
 
urlpatterns = [
    url(r'^index/$', index_view, name='main-view'),
    url(r'^weblog/', include('blog.urls')),
    ...
]

The view parameter is a view function or the result of as_view() for class-based views. It can also be an include().

The kwargs parameter allows you to pass additional arguments to the view function or method. See Passing extra options to view functions for an example.

See Naming URL patterns for why the name parameter is useful.

doc_Django
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.