{"title":"django.urls functions for use in URLconfs","version":"5.2","locale":"it","docname":"ref/urls","url":"/it/5.2/ref/urls/","canonical":"https://djangodocs.dev/it/5.2/ref/urls/","summary":"path() Link to this heading # path ( route , view , kwargs = None , name = None ) Link to this definition # Returns an element for inclusion in urlpatterns . For…","html":"<section id=\"module-django.urls.conf\">\n<span id=\"django-urls-functions-for-use-in-urlconfs\"></span><h1><code class=\"docutils literal notranslate\"><span class=\"pre\">django.urls</span></code> functions for use in URLconfs<a class=\"heading-anchor\" href=\"#module-django.urls.conf\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<section id=\"path\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">path()</span></code><a class=\"heading-anchor\" href=\"#path\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py function\">\n<dt class=\"sig sig-object py\" id=\"django.urls.path\">\n<span class=\"sig-name descname\"><span class=\"pre\">path</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">route</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">view</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">kwargs</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">name</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.urls.path\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Returns an element for inclusion in <code class=\"docutils literal notranslate\"><span class=\"pre\">urlpatterns</span></code>. For example:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">django.urls</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">include</span><span class=\"p\">,</span> <span class=\"n\">path</span>\n\n<span class=\"n\">urlpatterns</span> <span class=\"o\">=</span> <span class=\"p\">[</span>\n    <span class=\"n\">path</span><span class=\"p\">(</span><span class=\"s2\">&quot;index/&quot;</span><span class=\"p\">,</span> <span class=\"n\">views</span><span class=\"o\">.</span><span class=\"n\">index</span><span class=\"p\">,</span> <span class=\"n\">name</span><span class=\"o\">=</span><span class=\"s2\">&quot;main-view&quot;</span><span class=\"p\">),</span>\n    <span class=\"n\">path</span><span class=\"p\">(</span><span class=\"s2\">&quot;bio/&lt;username&gt;/&quot;</span><span class=\"p\">,</span> <span class=\"n\">views</span><span class=\"o\">.</span><span class=\"n\">bio</span><span class=\"p\">,</span> <span class=\"n\">name</span><span class=\"o\">=</span><span class=\"s2\">&quot;bio&quot;</span><span class=\"p\">),</span>\n    <span class=\"n\">path</span><span class=\"p\">(</span><span class=\"s2\">&quot;articles/&lt;slug:title&gt;/&quot;</span><span class=\"p\">,</span> <span class=\"n\">views</span><span class=\"o\">.</span><span class=\"n\">article</span><span class=\"p\">,</span> <span class=\"n\">name</span><span class=\"o\">=</span><span class=\"s2\">&quot;article-detail&quot;</span><span class=\"p\">),</span>\n    <span class=\"n\">path</span><span class=\"p\">(</span><span class=\"s2\">&quot;articles/&lt;slug:title&gt;/&lt;int:section&gt;/&quot;</span><span class=\"p\">,</span> <span class=\"n\">views</span><span class=\"o\">.</span><span class=\"n\">section</span><span class=\"p\">,</span> <span class=\"n\">name</span><span class=\"o\">=</span><span class=\"s2\">&quot;article-section&quot;</span><span class=\"p\">),</span>\n    <span class=\"n\">path</span><span class=\"p\">(</span><span class=\"s2\">&quot;blog/&quot;</span><span class=\"p\">,</span> <span class=\"n\">include</span><span class=\"p\">(</span><span class=\"s2\">&quot;blog.urls&quot;</span><span class=\"p\">)),</span>\n    <span class=\"o\">...</span><span class=\"p\">,</span>\n<span class=\"p\">]</span>\n</code></pre></div>\n<section id=\"route\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">route</span></code><a class=\"heading-anchor\" href=\"#route\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <code class=\"docutils literal notranslate\"><span class=\"pre\">route</span></code> argument should be a string or\n<a class=\"reference internal\" href=\"/it/5.2/ref/utils/#django.utils.translation.gettext_lazy\" title=\"django.utils.translation.gettext_lazy\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">gettext_lazy()</span></code></a> (see\n<a class=\"reference internal\" href=\"/it/5.2/topics/i18n/translation/#translating-urlpatterns\"><span class=\"std std-ref\">Translating URL patterns</span></a>) that contains a URL pattern. The string\nmay contain angle brackets (like <code class=\"docutils literal notranslate\"><span class=\"pre\">&lt;username&gt;</span></code> above) to capture part of the\nURL and send it as a keyword argument to the view. The angle brackets may\ninclude a converter specification (like the <code class=\"docutils literal notranslate\"><span class=\"pre\">int</span></code> part of <code class=\"docutils literal notranslate\"><span class=\"pre\">&lt;int:section&gt;</span></code>)\nwhich limits the characters matched and may also change the type of the\nvariable passed to the view. For example, <code class=\"docutils literal notranslate\"><span class=\"pre\">&lt;int:section&gt;</span></code> matches a string\nof decimal digits and converts the value to an <code class=\"docutils literal notranslate\"><span class=\"pre\">int</span></code>.</p>\n<p>When processing a request, Django starts at the first pattern in\n<code class=\"docutils literal notranslate\"><span class=\"pre\">urlpatterns</span></code> and makes its way down the list, comparing the requested URL\nagainst each pattern until it finds one that matches. See\n<a class=\"reference internal\" href=\"/it/5.2/topics/http/urls/#how-django-processes-a-request\"><span class=\"std std-ref\">How Django processes a request</span></a> for more details.</p>\n<p>Patterns don’t match GET and POST parameters, or the domain name. For example,\nin a request to <code class=\"docutils literal notranslate\"><span class=\"pre\">https://www.example.com/myapp/</span></code>, the URLconf will look for\n<code class=\"docutils literal notranslate\"><span class=\"pre\">myapp/</span></code>. In a request to <code class=\"docutils literal notranslate\"><span class=\"pre\">https://www.example.com/myapp/?page=3</span></code>, the\nURLconf will also look for <code class=\"docutils literal notranslate\"><span class=\"pre\">myapp/</span></code>.</p>\n</section>\n<section id=\"view\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">view</span></code><a class=\"heading-anchor\" href=\"#view\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <code class=\"docutils literal notranslate\"><span class=\"pre\">view</span></code> argument is a view function or the result of\n<a class=\"reference internal\" href=\"/it/5.2/ref/class-based-views/base/#django.views.generic.base.View.as_view\" title=\"django.views.generic.base.View.as_view\"><code class=\"xref py py-meth docutils literal notranslate\"><span class=\"pre\">as_view()</span></code></a> for class-based views. It can\nalso be a <a class=\"reference internal\" href=\"#django.urls.include\" title=\"django.urls.include\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">django.urls.include()</span></code></a>.</p>\n<p>When Django finds a matching pattern, it calls the specified view function with\nan <a class=\"reference internal\" href=\"/it/5.2/ref/request-response/#django.http.HttpRequest\" title=\"django.http.HttpRequest\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">HttpRequest</span></code></a> object as the first argument and any\n«captured» values from the route as keyword arguments.</p>\n</section>\n<section id=\"kwargs\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">kwargs</span></code><a class=\"heading-anchor\" href=\"#kwargs\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The <code class=\"docutils literal notranslate\"><span class=\"pre\">kwargs</span></code> argument allows you to pass additional arguments to the view\nfunction or method. See <a class=\"reference internal\" href=\"/it/5.2/topics/http/urls/#views-extra-options\"><span class=\"std std-ref\">Passing extra options to view functions</span></a> for an example.</p>\n</section>\n<section id=\"name\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">name</span></code><a class=\"heading-anchor\" href=\"#name\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Naming your URL lets you refer to it unambiguously from elsewhere in Django,\nespecially from within templates. This powerful feature allows you to make\nglobal changes to the URL patterns of your project while only touching a single\nfile.</p>\n<p>See <a class=\"reference internal\" href=\"/it/5.2/topics/http/urls/#naming-url-patterns\"><span class=\"std std-ref\">Naming URL patterns</span></a> for why the <code class=\"docutils literal notranslate\"><span class=\"pre\">name</span></code>\nargument is useful.</p>\n</section>\n</section>\n<section id=\"re-path\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">re_path()</span></code><a class=\"heading-anchor\" href=\"#re-path\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py function\">\n<dt class=\"sig sig-object py\" id=\"django.urls.re_path\">\n<span class=\"sig-name descname\"><span class=\"pre\">re_path</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">route</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">view</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">kwargs</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">name</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.urls.re_path\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Returns an element for inclusion in <code class=\"docutils literal notranslate\"><span class=\"pre\">urlpatterns</span></code>. For example:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">django.urls</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">include</span><span class=\"p\">,</span> <span class=\"n\">re_path</span>\n\n<span class=\"n\">urlpatterns</span> <span class=\"o\">=</span> <span class=\"p\">[</span>\n    <span class=\"n\">re_path</span><span class=\"p\">(</span><span class=\"sa\">r</span><span class=\"s2\">&quot;^index/$&quot;</span><span class=\"p\">,</span> <span class=\"n\">views</span><span class=\"o\">.</span><span class=\"n\">index</span><span class=\"p\">,</span> <span class=\"n\">name</span><span class=\"o\">=</span><span class=\"s2\">&quot;index&quot;</span><span class=\"p\">),</span>\n    <span class=\"n\">re_path</span><span class=\"p\">(</span><span class=\"sa\">r</span><span class=\"s2\">&quot;^bio/(?P&lt;username&gt;\\w+)/$&quot;</span><span class=\"p\">,</span> <span class=\"n\">views</span><span class=\"o\">.</span><span class=\"n\">bio</span><span class=\"p\">,</span> <span class=\"n\">name</span><span class=\"o\">=</span><span class=\"s2\">&quot;bio&quot;</span><span class=\"p\">),</span>\n    <span class=\"n\">re_path</span><span class=\"p\">(</span><span class=\"sa\">r</span><span class=\"s2\">&quot;^blog/&quot;</span><span class=\"p\">,</span> <span class=\"n\">include</span><span class=\"p\">(</span><span class=\"s2\">&quot;blog.urls&quot;</span><span class=\"p\">)),</span>\n    <span class=\"o\">...</span><span class=\"p\">,</span>\n<span class=\"p\">]</span>\n</code></pre></div>\n<p>The <code class=\"docutils literal notranslate\"><span class=\"pre\">route</span></code> argument should be a string or\n<a class=\"reference internal\" href=\"/it/5.2/ref/utils/#django.utils.translation.gettext_lazy\" title=\"django.utils.translation.gettext_lazy\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">gettext_lazy()</span></code></a> (see\n<a class=\"reference internal\" href=\"/it/5.2/topics/i18n/translation/#translating-urlpatterns\"><span class=\"std std-ref\">Translating URL patterns</span></a>) that contains a regular expression compatible\nwith Python’s <a class=\"reference external\" href=\"https://docs.python.org/3/library/re.html#module-re\" title=\"(in Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\"><span class=\"pre\">re</span></code></a> module. Strings typically use raw string syntax\n(<code class=\"docutils literal notranslate\"><span class=\"pre\">r''</span></code>) so that they can contain sequences like <code class=\"docutils literal notranslate\"><span class=\"pre\">\\d</span></code> without the need to\nescape the backslash with another backslash. When a match is made, captured\ngroups from the regular expression are passed to the view – as named arguments\nif the groups are named, and as positional arguments otherwise. The values are\npassed as strings, without any type conversion.</p>\n<p>When a <code class=\"docutils literal notranslate\"><span class=\"pre\">route</span></code> ends with <code class=\"docutils literal notranslate\"><span class=\"pre\">$</span></code> the whole requested URL, matching against\n<a class=\"reference internal\" href=\"/it/5.2/ref/request-response/#django.http.HttpRequest.path_info\" title=\"django.http.HttpRequest.path_info\"><code class=\"xref py py-attr docutils literal notranslate\"><span class=\"pre\">path_info</span></code></a>, must match the regular expression\npattern (<a class=\"reference external\" href=\"https://docs.python.org/3/library/re.html#re.fullmatch\" title=\"(in Python v3.14)\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">re.fullmatch()</span></code></a> is used).</p>\n<p>The <code class=\"docutils literal notranslate\"><span class=\"pre\">view</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">kwargs</span></code> and <code class=\"docutils literal notranslate\"><span class=\"pre\">name</span></code> arguments are the same as for\n<a class=\"reference internal\" href=\"#django.urls.path\" title=\"django.urls.path\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">path()</span></code></a>.</p>\n</section>\n<section id=\"include\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">include()</span></code><a class=\"heading-anchor\" href=\"#include\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py function\">\n<dt class=\"sig sig-object py\" id=\"django.urls.include\">\n<span class=\"sig-name descname\"><span class=\"pre\">include</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">module</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">namespace</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.urls.include\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dt class=\"sig sig-object py\">\n<span class=\"sig-name descname\"><span class=\"pre\">include</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">pattern_list</span></span></em><span class=\"sig-paren\">)</span></dt>\n<dt class=\"sig sig-object py\">\n<span class=\"sig-name descname\"><span class=\"pre\">include</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">(pattern_list</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">app_namespace)</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">namespace=None</span></span></em><span class=\"sig-paren\">)</span></dt>\n<dd><p>A function that takes a full Python import path to another URLconf module\nthat should be «included» in this place. Optionally, the <a class=\"reference internal\" href=\"/it/5.2/topics/http/urls/#term-application-namespace\"><span class=\"xref std std-term\">application\nnamespace</span></a> and <a class=\"reference internal\" href=\"/it/5.2/topics/http/urls/#term-instance-namespace\"><span class=\"xref std std-term\">instance namespace</span></a> where the entries will be included\ninto can also be specified.</p>\n<p>Usually, the application namespace should be specified by the included\nmodule. If an application namespace is set, the <code class=\"docutils literal notranslate\"><span class=\"pre\">namespace</span></code> argument\ncan be used to set a different instance namespace.</p>\n<p><code class=\"docutils literal notranslate\"><span class=\"pre\">include()</span></code> also accepts as an argument either an iterable that returns\nURL patterns or a 2-tuple containing such iterable plus the names of the\napplication namespaces.</p>\n<dl class=\"field-list simple\">\n<dt class=\"field-odd\">Parametri<span class=\"colon\">:</span></dt>\n<dd class=\"field-odd\"><ul class=\"simple\">\n<li><p><strong>module</strong> – URLconf module (or module name)</p></li>\n<li><p><strong>namespace</strong> (<a class=\"reference external\" href=\"https://docs.python.org/3/library/stdtypes.html#str\" title=\"(in Python v3.14)\"><em>str</em></a>) – Instance namespace for the URL entries being included</p></li>\n<li><p><strong>pattern_list</strong> – Iterable of <a class=\"reference internal\" href=\"#django.urls.path\" title=\"django.urls.path\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">path()</span></code></a> and/or <a class=\"reference internal\" href=\"#django.urls.re_path\" title=\"django.urls.re_path\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">re_path()</span></code></a> instances.</p></li>\n<li><p><strong>app_namespace</strong> (<a class=\"reference external\" href=\"https://docs.python.org/3/library/stdtypes.html#str\" title=\"(in Python v3.14)\"><em>str</em></a>) – Application namespace for the URL entries being included</p></li>\n</ul>\n</dd>\n</dl>\n</dd></dl>\n\n<p>See <a class=\"reference internal\" href=\"/it/5.2/topics/http/urls/#including-other-urlconfs\"><span class=\"std std-ref\">Including other URLconfs</span></a> and <a class=\"reference internal\" href=\"/it/5.2/topics/http/urls/#namespaces-and-include\"><span class=\"std std-ref\">URL namespaces and included URLconfs</span></a>.</p>\n</section>\n<section id=\"register-converter\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">register_converter()</span></code><a class=\"heading-anchor\" href=\"#register-converter\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py function\">\n<dt class=\"sig sig-object py\" id=\"django.urls.register_converter\">\n<span class=\"sig-name descname\"><span class=\"pre\">register_converter</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">converter</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">type_name</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.urls.register_converter\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>The function for registering a converter for use in <a class=\"reference internal\" href=\"#django.urls.path\" title=\"django.urls.path\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">path()</span></code></a>\n<code class=\"docutils literal notranslate\"><span class=\"pre\">route</span></code>s.</p>\n<p>The <code class=\"docutils literal notranslate\"><span class=\"pre\">converter</span></code> argument is a converter class, and <code class=\"docutils literal notranslate\"><span class=\"pre\">type_name</span></code> is the\nconverter name to use in path patterns. See\n<a class=\"reference internal\" href=\"/it/5.2/topics/http/urls/#registering-custom-path-converters\"><span class=\"std std-ref\">Registering custom path converters</span></a> for an example.</p>\n<aside class=\"version-note version-deprecated\" data-version=\"5.1\">\n<p class=\"version-note-title\">Deprecated since Django 5.1</p><p><span class=\"versionmodified deprecated\">Deprecato dalla versione 5.1: </span>Overriding existing converters is deprecated.</p>\n</aside>\n</section>\n</section>\n<section id=\"module-django.conf.urls\">\n<span id=\"django-conf-urls-functions-for-use-in-urlconfs\"></span><h1><code class=\"docutils literal notranslate\"><span class=\"pre\">django.conf.urls</span></code> functions for use in URLconfs<a class=\"heading-anchor\" href=\"#module-django.conf.urls\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<section id=\"static\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">static()</span></code><a class=\"heading-anchor\" href=\"#static\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py function\">\n<dt class=\"sig sig-object py\" id=\"django.conf.urls.static.static\">\n<span class=\"sig-prename descclassname\"><span class=\"pre\">static.</span></span><span class=\"sig-name descname\"><span class=\"pre\">static</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">prefix</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">view</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">django.views.static.serve</span></span></em>, <em class=\"sig-param\"><span class=\"o\"><span class=\"pre\">**</span></span><span class=\"n\"><span class=\"pre\">kwargs</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.conf.urls.static.static\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Helper function to return a URL pattern for serving files in debug mode:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">django.conf</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">settings</span>\n<span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">django.conf.urls.static</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">static</span>\n\n<span class=\"n\">urlpatterns</span> <span class=\"o\">=</span> <span class=\"p\">[</span>\n    <span class=\"c1\"># ... the rest of your URLconf goes here ...</span>\n<span class=\"p\">]</span> <span class=\"o\">+</span> <span class=\"n\">static</span><span class=\"p\">(</span><span class=\"n\">settings</span><span class=\"o\">.</span><span class=\"n\">MEDIA_URL</span><span class=\"p\">,</span> <span class=\"n\">document_root</span><span class=\"o\">=</span><span class=\"n\">settings</span><span class=\"o\">.</span><span class=\"n\">MEDIA_ROOT</span><span class=\"p\">)</span>\n</code></pre></div>\n</section>\n<section id=\"handler400\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">handler400</span></code><a class=\"heading-anchor\" href=\"#handler400\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py data\">\n<dt class=\"sig sig-object py\" id=\"django.conf.urls.handler400\">\n<span class=\"sig-name descname\"><span class=\"pre\">handler400</span></span><a class=\"heading-anchor\" href=\"#django.conf.urls.handler400\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A callable, or a string representing the full Python import path to the view\nthat should be called if the HTTP client has sent a request that caused an error\ncondition and a response with a status code of 400.</p>\n<p>By default, this is <a class=\"reference internal\" href=\"/it/5.2/ref/views/#django.views.defaults.bad_request\" title=\"django.views.defaults.bad_request\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">django.views.defaults.bad_request()</span></code></a>. If you\nimplement a custom view, be sure it accepts <code class=\"docutils literal notranslate\"><span class=\"pre\">request</span></code> and <code class=\"docutils literal notranslate\"><span class=\"pre\">exception</span></code>\narguments and returns an <a class=\"reference internal\" href=\"/it/5.2/ref/request-response/#django.http.HttpResponseBadRequest\" title=\"django.http.HttpResponseBadRequest\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">HttpResponseBadRequest</span></code></a>.</p>\n</section>\n<section id=\"handler403\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">handler403</span></code><a class=\"heading-anchor\" href=\"#handler403\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py data\">\n<dt class=\"sig sig-object py\" id=\"django.conf.urls.handler403\">\n<span class=\"sig-name descname\"><span class=\"pre\">handler403</span></span><a class=\"heading-anchor\" href=\"#django.conf.urls.handler403\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A callable, or a string representing the full Python import path to the view\nthat should be called if the user doesn’t have the permissions required to\naccess a resource.</p>\n<p>By default, this is <a class=\"reference internal\" href=\"/it/5.2/ref/views/#django.views.defaults.permission_denied\" title=\"django.views.defaults.permission_denied\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">django.views.defaults.permission_denied()</span></code></a>. If you\nimplement a custom view, be sure it accepts <code class=\"docutils literal notranslate\"><span class=\"pre\">request</span></code> and <code class=\"docutils literal notranslate\"><span class=\"pre\">exception</span></code>\narguments and returns an <a class=\"reference internal\" href=\"/it/5.2/ref/request-response/#django.http.HttpResponseForbidden\" title=\"django.http.HttpResponseForbidden\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">HttpResponseForbidden</span></code></a>.</p>\n</section>\n<section id=\"handler404\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">handler404</span></code><a class=\"heading-anchor\" href=\"#handler404\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py data\">\n<dt class=\"sig sig-object py\" id=\"django.conf.urls.handler404\">\n<span class=\"sig-name descname\"><span class=\"pre\">handler404</span></span><a class=\"heading-anchor\" href=\"#django.conf.urls.handler404\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A callable, or a string representing the full Python import path to the view\nthat should be called if none of the URL patterns match.</p>\n<p>By default, this is <a class=\"reference internal\" href=\"/it/5.2/ref/views/#django.views.defaults.page_not_found\" title=\"django.views.defaults.page_not_found\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">django.views.defaults.page_not_found()</span></code></a>. If you\nimplement a custom view, be sure it accepts <code class=\"docutils literal notranslate\"><span class=\"pre\">request</span></code> and <code class=\"docutils literal notranslate\"><span class=\"pre\">exception</span></code>\narguments and returns an <a class=\"reference internal\" href=\"/it/5.2/ref/request-response/#django.http.HttpResponseNotFound\" title=\"django.http.HttpResponseNotFound\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">HttpResponseNotFound</span></code></a>.</p>\n</section>\n<section id=\"handler500\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">handler500</span></code><a class=\"heading-anchor\" href=\"#handler500\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py data\">\n<dt class=\"sig sig-object py\" id=\"django.conf.urls.handler500\">\n<span class=\"sig-name descname\"><span class=\"pre\">handler500</span></span><a class=\"heading-anchor\" href=\"#django.conf.urls.handler500\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A callable, or a string representing the full Python import path to the view\nthat should be called in case of server errors. Server errors happen when you\nhave runtime errors in view code.</p>\n<p>By default, this is <a class=\"reference internal\" href=\"/it/5.2/ref/views/#django.views.defaults.server_error\" title=\"django.views.defaults.server_error\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">django.views.defaults.server_error()</span></code></a>. If you\nimplement a custom view, be sure it accepts a <code class=\"docutils literal notranslate\"><span class=\"pre\">request</span></code> argument and returns\nan <a class=\"reference internal\" href=\"/it/5.2/ref/request-response/#django.http.HttpResponseServerError\" title=\"django.http.HttpResponseServerError\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">HttpResponseServerError</span></code></a>.</p>\n</section>\n</section>\n","rootId":"","toc":[{"title":"django.urls functions for use in URLconfs","anchor":"","children":[{"title":"path()","anchor":"path","children":[{"title":"route","anchor":"route","children":[]},{"title":"view","anchor":"view","children":[]},{"title":"kwargs","anchor":"kwargs","children":[]},{"title":"name","anchor":"name","children":[]}]},{"title":"re_path()","anchor":"re-path","children":[]},{"title":"include()","anchor":"include","children":[]},{"title":"register_converter()","anchor":"register-converter","children":[]}]},{"title":"django.conf.urls functions for use in URLconfs","anchor":"module-django.conf.urls","children":[{"title":"static()","anchor":"static","children":[]},{"title":"handler400","anchor":"handler400","children":[]},{"title":"handler403","anchor":"handler403","children":[]},{"title":"handler404","anchor":"handler404","children":[]},{"title":"handler500","anchor":"handler500","children":[]}]}],"breadcrumbs":[{"docname":"ref/index","title":"API Reference","url":"/it/5.2/ref/"}],"prev":{"docname":"ref/urlresolvers","title":"django.urls utility functions","url":"/it/5.2/ref/urlresolvers/"},"next":{"docname":"ref/utils","title":"Django Utils","url":"/it/5.2/ref/utils/"},"formats":{"html":"/it/5.2/ref/urls/","markdown":"/it/5.2/ref/urls.md","json":"/it/5.2/ref/urls.json"},"source":"https://github.com/django/django/blob/stable/5.2.x/docs/ref/urls.txt","official":"https://docs.djangoproject.com/it/5.2/ref/urls/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2"],"inLocales":["en","sv","zh-hans","ga","fr","ja","id","it","pt-br","ko","es","el","pl"]}