=============================================``django.urls`` functions for use in URLconfs=============================================.. module:: django.urls.conf:synopsis: Functions for use in URLconfs... currentmodule:: django.urls``path()``==========.. function:: path(route, view, kwargs=None, name=None)Returns an element for inclusion in ``urlpatterns``. For example::from django.urls import include, pathurlpatterns = [path('index/', views.index, name='main-view'),path('bio/<username>/', views.bio, name='bio'),path('articles/<slug:title>/', views.article, name='article-detail'),path('articles/<slug:title>/<int:section>/', views.section, name='article-section'),path('blog/', include('blog.urls')),...]The ``route`` argument should be a string or:func:`~django.utils.translation.gettext_lazy()` (see:ref:`translating-urlpatterns`) that contains a URL pattern. The stringmay contain angle brackets (like ``<username>`` above) to capture part of theURL and send it as a keyword argument to the view. The angle brackets mayinclude a converter specification (like the ``int`` part of ``<int:section>``)which limits the characters matched and may also change the type of thevariable passed to the view. For example, ``<int:section>`` matches a stringof decimal digits and converts the value to an ``int``. See:ref:`how-django-processes-a-request` for more details.The ``view`` argument is a view function or the result of:meth:`~django.views.generic.base.View.as_view` for class-based views. It canalso be an :func:`django.urls.include`.The ``kwargs`` argument allows you to pass additional arguments to the viewfunction or method. See :ref:`views-extra-options` for an example.See :ref:`Naming URL patterns <naming-url-patterns>` for why the ``name``argument is useful.``re_path()``=============.. function:: re_path(route, view, kwargs=None, name=None)Returns an element for inclusion in ``urlpatterns``. For example::from django.urls import include, re_pathurlpatterns = [re_path(r'^index/$', views.index, name='index'),re_path(r'^bio/(?P<username>\w+)/$', views.bio, name='bio'),re_path(r'^blog/', include('blog.urls')),...]The ``route`` argument should be a string or:func:`~django.utils.translation.gettext_lazy()` (see:ref:`translating-urlpatterns`) that contains a regular expression compatiblewith Python's :py:mod:`re` module. Strings typically use raw string syntax(``r''``) so that they can contain sequences like ``\d`` without the need toescape the backslash with another backslash. When a match is made, capturedgroups from the regular expression are passed to the view -- as named argumentsif the groups are named, and as positional arguments otherwise. The values arepassed as strings, without any type conversion.When a ``route`` ends with ``$`` the whole requested URL, matching against:attr:`~django.http.HttpRequest.path_info`, must match the regular expressionpattern (:py:func:`re.fullmatch` is used).The ``view``, ``kwargs`` and ``name`` arguments are the same as for:func:`~django.urls.path()`... versionchanged:: 2.2.25In older versions, a full-match wasn't required for a ``route`` which endswith ``$``.``include()``=============.. function:: include(module, namespace=None)include(pattern_list)include((pattern_list, app_namespace), namespace=None)A function that takes a full Python import path to another URLconf modulethat should be "included" in this place. Optionally, the :term:`applicationnamespace` and :term:`instance namespace` where the entries will be includedinto can also be specified.Usually, the application namespace should be specified by the includedmodule. If an application namespace is set, the ``namespace`` argumentcan be used to set a different instance namespace.``include()`` also accepts as an argument either an iterable that returnsURL patterns or a 2-tuple containing such iterable plus the names of theapplication namespaces.:arg module: URLconf module (or module name):arg namespace: Instance namespace for the URL entries being included:type namespace: str:arg pattern_list: Iterable of :func:`~django.urls.path` and/or :func:`~django.urls.re_path` instances.:arg app_namespace: Application namespace for the URL entries being included:type app_namespace: strSee :ref:`including-other-urlconfs` and :ref:`namespaces-and-include`.``register_converter()``========================.. function:: register_converter(converter, type_name)The function for registering a converter for use in :func:`~django.urls.path()```route``\s.The ``converter`` argument is a converter class, and ``type_name`` is theconverter name to use in path patterns. See:ref:`registering-custom-path-converters` for an example.==================================================``django.conf.urls`` functions for use in URLconfs==================================================.. module:: django.conf.urls``static()``============.. function:: static.static(prefix, view=django.views.static.serve, **kwargs)Helper function to return a URL pattern for serving files in debug mode::from django.conf import settingsfrom django.conf.urls.static import staticurlpatterns = [# ... the rest of your URLconf goes here ...] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)``handler400``==============.. data:: handler400A callable, or a string representing the full Python import path to the viewthat should be called if the HTTP client has sent a request that caused an errorcondition and a response with a status code of 400.By default, this is :func:`django.views.defaults.bad_request`. If youimplement a custom view, be sure it accepts ``request`` and ``exception``arguments and returns an :class:`~django.http.HttpResponseBadRequest`.``handler403``==============.. data:: handler403A callable, or a string representing the full Python import path to the viewthat should be called if the user doesn't have the permissions required toaccess a resource.By default, this is :func:`django.views.defaults.permission_denied`. If youimplement a custom view, be sure it accepts ``request`` and ``exception``arguments and returns an :class:`~django.http.HttpResponseForbidden`.``handler404``==============.. data:: handler404A callable, or a string representing the full Python import path to the viewthat should be called if none of the URL patterns match.By default, this is :func:`django.views.defaults.page_not_found`. If youimplement a custom view, be sure it accepts ``request`` and ``exception``arguments and returns an :class:`~django.http.HttpResponseNotFound`.``handler500``==============.. data:: handler500A callable, or a string representing the full Python import path to the viewthat should be called in case of server errors. Server errors happen when youhave runtime errors in view code.By default, this is :func:`django.views.defaults.server_error`. If youimplement a custom view, be sure it accepts a ``request`` argument and returnsan :class:`~django.http.HttpResponseServerError`.