{"title":"The staticfiles app","version":"3.0","locale":"es","docname":"ref/contrib/staticfiles","url":"/es/3.0/ref/contrib/staticfiles/","canonical":"https://djangodocs.dev/es/3.0/ref/contrib/staticfiles/","summary":"django.contrib.staticfiles collects static files from each of your applications (and any other places you specify) into a single location that can easily be served…","html":"<span id=\"the-staticfiles-app\"></span><h1>The <code class=\"docutils literal notranslate\"><span class=\"pre\">staticfiles</span></code> app<a class=\"heading-anchor\" href=\"#module-django.contrib.staticfiles\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p><code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.staticfiles</span></code> collects static files from each of your\napplications (and any other places you specify) into a single location that\ncan easily be served in production.</p>\n<aside class=\"admonition admonition-seealso\">\n<p class=\"admonition-title\">Ver también</p>\n<p>For an introduction to the static files app and some usage examples, see\n<a class=\"reference internal\" href=\"/es/3.0/howto/static-files/\"><span class=\"doc\">Managing static files (e.g. images, JavaScript, CSS)</span></a>. For guidelines on deploying static files,\nsee <a class=\"reference internal\" href=\"/es/3.0/howto/static-files/deployment/\"><span class=\"doc\">Deploying static files</span></a>.</p>\n</aside>\n<section id=\"settings\">\n<span id=\"staticfiles-settings\"></span><h2>Settings<a class=\"heading-anchor\" href=\"#settings\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>See <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#settings-staticfiles\"><span class=\"std std-ref\">staticfiles settings</span></a> for details on the\nfollowing settings:</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATIC_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATIC_ROOT</span></code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATIC_URL\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATIC_URL</span></code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATICFILES_DIRS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATICFILES_DIRS</span></code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATICFILES_STORAGE\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATICFILES_STORAGE</span></code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATICFILES_FINDERS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATICFILES_FINDERS</span></code></a></p></li>\n</ul>\n</section>\n<section id=\"management-commands\">\n<h2>Management Commands<a class=\"heading-anchor\" href=\"#management-commands\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p><code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.staticfiles</span></code> exposes three management commands.</p>\n<section id=\"collectstatic\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">collectstatic</span></code><a class=\"heading-anchor\" href=\"#collectstatic\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-collectstatic\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">collectstatic</span></span><a class=\"heading-anchor\" href=\"#django-admin-collectstatic\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Collects the static files into <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATIC_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATIC_ROOT</span></code></a>.</p>\n<p>Duplicate file names are by default resolved in a similar way to how template\nresolution works: the file that is first found in one of the specified\nlocations will be used. If you’re confused, the <a class=\"reference internal\" href=\"#django-admin-findstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">findstatic</span></code></a> command\ncan help show you which files are found.</p>\n<p>On subsequent <code class=\"docutils literal notranslate\"><span class=\"pre\">collectstatic</span></code> runs (if <code class=\"docutils literal notranslate\"><span class=\"pre\">STATIC_ROOT</span></code> isn’t empty), files\nare copied only if they have a modified timestamp greater than the timestamp of\nthe file in <code class=\"docutils literal notranslate\"><span class=\"pre\">STATIC_ROOT</span></code>. Therefore if you remove an application from\n<a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">INSTALLED_APPS</span></code></a>, it’s a good idea to use the <a class=\"reference internal\" href=\"#cmdoption-collectstatic-clear\"><code class=\"xref std std-option docutils literal notranslate\"><span class=\"pre\">collectstatic</span>\n<span class=\"pre\">--clear</span></code></a> option in order to remove stale static files.</p>\n<p>Files are searched by using the <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATICFILES_FINDERS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">enabled</span> <span class=\"pre\">finders</span></code></a>. The default is to look in all locations defined in\n<a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATICFILES_DIRS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATICFILES_DIRS</span></code></a> and in the <code class=\"docutils literal notranslate\"><span class=\"pre\">'static'</span></code> directory of apps\nspecified by the <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">INSTALLED_APPS</span></code></a> setting.</p>\n<p>The <a class=\"reference internal\" href=\"#django-admin-collectstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">collectstatic</span></code></a> management command calls the\n<a class=\"reference internal\" href=\"#django.contrib.staticfiles.storage.StaticFilesStorage.post_process\" title=\"django.contrib.staticfiles.storage.StaticFilesStorage.post_process\"><code class=\"xref py py-meth docutils literal notranslate\"><span class=\"pre\">post_process()</span></code></a>\nmethod of the <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATICFILES_STORAGE\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATICFILES_STORAGE</span></code></a> after each run and passes\na list of paths that have been found by the management command. It also\nreceives all command line options of <a class=\"reference internal\" href=\"#django-admin-collectstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">collectstatic</span></code></a>. This is used\nby the <a class=\"reference internal\" href=\"#django.contrib.staticfiles.storage.ManifestStaticFilesStorage\" title=\"django.contrib.staticfiles.storage.ManifestStaticFilesStorage\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">ManifestStaticFilesStorage</span></code></a>\nby default.</p>\n<p>By default, collected files receive permissions from\n<a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-FILE_UPLOAD_PERMISSIONS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">FILE_UPLOAD_PERMISSIONS</span></code></a> and collected directories receive permissions\nfrom <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-FILE_UPLOAD_DIRECTORY_PERMISSIONS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">FILE_UPLOAD_DIRECTORY_PERMISSIONS</span></code></a>. If you would like different\npermissions for these files and/or directories, you can subclass either of the\n<a class=\"reference internal\" href=\"#staticfiles-storages\"><span class=\"std std-ref\">static files storage classes</span></a> and specify the\n<code class=\"docutils literal notranslate\"><span class=\"pre\">file_permissions_mode</span></code> and/or <code class=\"docutils literal notranslate\"><span class=\"pre\">directory_permissions_mode</span></code> parameters,\nrespectively. 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.contrib.staticfiles</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">storage</span>\n\n<span class=\"k\">class</span><span class=\"w\"> </span><span class=\"nc\">MyStaticFilesStorage</span><span class=\"p\">(</span><span class=\"n\">storage</span><span class=\"o\">.</span><span class=\"n\">StaticFilesStorage</span><span class=\"p\">):</span>\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"fm\">__init__</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">,</span> <span class=\"o\">*</span><span class=\"n\">args</span><span class=\"p\">,</span> <span class=\"o\">**</span><span class=\"n\">kwargs</span><span class=\"p\">):</span>\n        <span class=\"n\">kwargs</span><span class=\"p\">[</span><span class=\"s1\">&#39;file_permissions_mode&#39;</span><span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"mo\">0o640</span>\n        <span class=\"n\">kwargs</span><span class=\"p\">[</span><span class=\"s1\">&#39;directory_permissions_mode&#39;</span><span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"mo\">0o760</span>\n        <span class=\"nb\">super</span><span class=\"p\">()</span><span class=\"o\">.</span><span class=\"fm\">__init__</span><span class=\"p\">(</span><span class=\"o\">*</span><span class=\"n\">args</span><span class=\"p\">,</span> <span class=\"o\">**</span><span class=\"n\">kwargs</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>Then set the <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATICFILES_STORAGE\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATICFILES_STORAGE</span></code></a> setting to\n<code class=\"docutils literal notranslate\"><span class=\"pre\">'path.to.MyStaticFilesStorage'</span></code>.</p>\n<p>Some commonly used options are:</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-collectstatic-noinput\">\n<span id=\"cmdoption-collectstatic-no-input\"></span><span class=\"sig-name descname\"><span class=\"pre\">--noinput</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">--no-input</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-collectstatic-noinput\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Do NOT prompt the user for input of any kind.</p>\n</dd></dl>\n\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-collectstatic-ignore\">\n<span id=\"cmdoption-collectstatic-i\"></span><span class=\"sig-name descname\"><span class=\"pre\">--ignore</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">PATTERN</span></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-i</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">PATTERN</span></span><a class=\"heading-anchor\" href=\"#cmdoption-collectstatic-ignore\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Ignore files, directories, or paths matching this glob-style pattern. Use\nmultiple times to ignore more. When specifying a path, always use forward\nslashes, even on Windows.</p>\n<aside class=\"version-note version-changed\" data-version=\"2.2\">\n<p class=\"version-note-title\">Changed in Django 2.2</p><p>Path matching was added.</p>\n</aside>\n</dd></dl>\n\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-collectstatic-dry-run\">\n<span id=\"cmdoption-collectstatic-n\"></span><span class=\"sig-name descname\"><span class=\"pre\">--dry-run</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-n</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-collectstatic-dry-run\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Do everything except modify the filesystem.</p>\n</dd></dl>\n\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-collectstatic-clear\">\n<span id=\"cmdoption-collectstatic-c\"></span><span class=\"sig-name descname\"><span class=\"pre\">--clear</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-c</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-collectstatic-clear\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Clear the existing files before trying to copy or link the original file.</p>\n</dd></dl>\n\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-collectstatic-link\">\n<span id=\"cmdoption-collectstatic-l\"></span><span class=\"sig-name descname\"><span class=\"pre\">--link</span></span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\"><span class=\"pre\">,</span> </span><span class=\"sig-name descname\"><span class=\"pre\">-l</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-collectstatic-link\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Create a symbolic link to each file instead of copying.</p>\n</dd></dl>\n\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-collectstatic-no-post-process\">\n<span class=\"sig-name descname\"><span class=\"pre\">--no-post-process</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-collectstatic-no-post-process\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Don’t call the\n<a class=\"reference internal\" href=\"#django.contrib.staticfiles.storage.StaticFilesStorage.post_process\" title=\"django.contrib.staticfiles.storage.StaticFilesStorage.post_process\"><code class=\"xref py py-meth docutils literal notranslate\"><span class=\"pre\">post_process()</span></code></a>\nmethod of the configured <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATICFILES_STORAGE\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATICFILES_STORAGE</span></code></a> storage backend.</p>\n</dd></dl>\n\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-collectstatic-no-default-ignore\">\n<span class=\"sig-name descname\"><span class=\"pre\">--no-default-ignore</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-collectstatic-no-default-ignore\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Don’t ignore the common private glob-style patterns <code class=\"docutils literal notranslate\"><span class=\"pre\">'CVS'</span></code>, <code class=\"docutils literal notranslate\"><span class=\"pre\">'.*'</span></code>\nand <code class=\"docutils literal notranslate\"><span class=\"pre\">'*~'</span></code>.</p>\n</dd></dl>\n\n<p>For a full list of options, refer to the commands own help by running:</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-0-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</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=\"Shell code\"><code><span class=\"gp\">$ </span>python<span class=\"w\"> </span>manage.py<span class=\"w\"> </span>collectstatic<span class=\"w\"> </span>--help\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-0-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</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=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> py manage.py collectstatic --help\n</code></pre></div></div></div>\n<section id=\"customizing-the-ignored-pattern-list\">\n<span id=\"customize-staticfiles-ignore-patterns\"></span><h4>Customizing the ignored pattern list<a class=\"heading-anchor\" href=\"#customizing-the-ignored-pattern-list\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>The default ignored pattern list, <code class=\"docutils literal notranslate\"><span class=\"pre\">['CVS',</span> <span class=\"pre\">'.*',</span> <span class=\"pre\">'*~']</span></code>, can be customized in\na more persistent way than providing the <code class=\"docutils literal notranslate\"><span class=\"pre\">--ignore</span></code> command option at each\n<code class=\"docutils literal notranslate\"><span class=\"pre\">collectstatic</span></code> invocation. Provide a custom <a class=\"reference internal\" href=\"/es/3.0/ref/applications/#django.apps.AppConfig\" title=\"django.apps.AppConfig\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">AppConfig</span></code></a>\nclass, override the <code class=\"docutils literal notranslate\"><span class=\"pre\">ignore_patterns</span></code> attribute of this class and replace\n<code class=\"docutils literal notranslate\"><span class=\"pre\">'django.contrib.staticfiles'</span></code> with that class path in your\n<a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">INSTALLED_APPS</span></code></a> setting:</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.contrib.staticfiles.apps</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">StaticFilesConfig</span>\n\n<span class=\"k\">class</span><span class=\"w\"> </span><span class=\"nc\">MyStaticFilesConfig</span><span class=\"p\">(</span><span class=\"n\">StaticFilesConfig</span><span class=\"p\">):</span>\n    <span class=\"n\">ignore_patterns</span> <span class=\"o\">=</span> <span class=\"p\">[</span><span class=\"o\">...</span><span class=\"p\">]</span>  <span class=\"c1\"># your custom ignore list</span>\n</code></pre></div>\n</section>\n</section>\n<section id=\"findstatic\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">findstatic</span></code><a class=\"heading-anchor\" href=\"#findstatic\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\" id=\"django-admin-findstatic\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">findstatic</span> <span class=\"pre\">staticfile</span> <span class=\"pre\">[staticfile</span> <span class=\"pre\">...]</span></span><a class=\"heading-anchor\" href=\"#django-admin-findstatic\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Searches for one or more relative paths with the enabled finders.</p>\n<p>For example:</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-1-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</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=\"Shell code\"><code><span class=\"gp\">$ </span>python<span class=\"w\"> </span>manage.py<span class=\"w\"> </span>findstatic<span class=\"w\"> </span>css/base.css<span class=\"w\"> </span>admin/js/core.js\n<span class=\"go\">Found &#39;css/base.css&#39; here:</span>\n<span class=\"go\">  /home/special.polls.com/core/static/css/base.css</span>\n<span class=\"go\">  /home/polls.com/core/static/css/base.css</span>\n<span class=\"go\">Found &#39;admin/js/core.js&#39; here:</span>\n<span class=\"go\">  /home/polls.com/src/django/contrib/admin/media/js/core.js</span>\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-1-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</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=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> py manage.py findstatic css\\base.css admin\\js\\core.js\n<span class=\"go\">Found &#39;css/base.css&#39; here:</span>\n<span class=\"go\">  /home/special.polls.com/core/static/css/base.css</span>\n<span class=\"go\">  /home/polls.com/core/static/css/base.css</span>\n<span class=\"go\">Found &#39;admin/js/core.js&#39; here:</span>\n<span class=\"go\">  /home/polls.com/src/django/contrib/admin/media/js/core.js</span>\n</code></pre></div></div></div>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-findstatic-arg-findstatic\">\n<span class=\"sig-name descname\"><span class=\"pre\">findstatic</span></span><span class=\"sig-prename descclassname\"> <span class=\"pre\">--first</span></span><a class=\"heading-anchor\" href=\"#cmdoption-findstatic-arg-findstatic\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>By default, all matching locations are found. To only return the first match\nfor each relative path, use the <code class=\"docutils literal notranslate\"><span class=\"pre\">--first</span></code> option:</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-2-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</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=\"Shell code\"><code><span class=\"gp\">$ </span>python<span class=\"w\"> </span>manage.py<span class=\"w\"> </span>findstatic<span class=\"w\"> </span>css/base.css<span class=\"w\"> </span>--first\n<span class=\"go\">Found &#39;css/base.css&#39; here:</span>\n<span class=\"go\">  /home/special.polls.com/core/static/css/base.css</span>\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-2-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</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=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> py manage.py findstatic css\\base.css --first\n<span class=\"go\">Found &#39;css/base.css&#39; here:</span>\n<span class=\"go\">  /home/special.polls.com/core/static/css/base.css</span>\n</code></pre></div></div></div>\n<p>This is a debugging aid; it’ll show you exactly which static file will be\ncollected for a given path.</p>\n<p>By setting the <code class=\"docutils literal notranslate\"><span class=\"pre\">--verbosity</span></code> flag to 0, you can suppress the extra output and\njust get the path names:</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-3-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</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=\"Shell code\"><code><span class=\"gp\">$ </span>python<span class=\"w\"> </span>manage.py<span class=\"w\"> </span>findstatic<span class=\"w\"> </span>css/base.css<span class=\"w\"> </span>--verbosity<span class=\"w\"> </span><span class=\"m\">0</span>\n<span class=\"go\">/home/special.polls.com/core/static/css/base.css</span>\n<span class=\"go\">/home/polls.com/core/static/css/base.css</span>\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-3-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</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=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> py manage.py findstatic css\\base.css --verbosity 0\n<span class=\"go\">/home/special.polls.com/core/static/css/base.css</span>\n<span class=\"go\">/home/polls.com/core/static/css/base.css</span>\n</code></pre></div></div></div>\n<p>On the other hand, by setting the <code class=\"docutils literal notranslate\"><span class=\"pre\">--verbosity</span></code> flag to 2, you can get all\nthe directories which were searched:</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-4-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</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=\"Shell code\"><code><span class=\"gp\">$ </span>python<span class=\"w\"> </span>manage.py<span class=\"w\"> </span>findstatic<span class=\"w\"> </span>css/base.css<span class=\"w\"> </span>--verbosity<span class=\"w\"> </span><span class=\"m\">2</span>\n<span class=\"go\">Found &#39;css/base.css&#39; here:</span>\n<span class=\"go\">  /home/special.polls.com/core/static/css/base.css</span>\n<span class=\"go\">  /home/polls.com/core/static/css/base.css</span>\n<span class=\"go\">Looking in the following locations:</span>\n<span class=\"go\">  /home/special.polls.com/core/static</span>\n<span class=\"go\">  /home/polls.com/core/static</span>\n<span class=\"go\">  /some/other/path/static</span>\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-4-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</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=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> py manage.py findstatic css\\base.css --verbosity 2\n<span class=\"go\">Found &#39;css/base.css&#39; here:</span>\n<span class=\"go\">  /home/special.polls.com/core/static/css/base.css</span>\n<span class=\"go\">  /home/polls.com/core/static/css/base.css</span>\n<span class=\"go\">Looking in the following locations:</span>\n<span class=\"go\">  /home/special.polls.com/core/static</span>\n<span class=\"go\">  /home/polls.com/core/static</span>\n<span class=\"go\">  /some/other/path/static</span>\n</code></pre></div></div></div>\n</section>\n<section id=\"runserver\">\n<span id=\"staticfiles-runserver\"></span><h3><code class=\"docutils literal notranslate\"><span class=\"pre\">runserver</span></code><a class=\"heading-anchor\" href=\"#runserver\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"std django-admin\">\n<dt class=\"sig sig-object std\">\n<span class=\"sig-name descname\"><span class=\"pre\">django-admin</span> <span class=\"pre\">runserver</span> <span class=\"pre\">[addrport]</span></span></dt>\n<dd></dd></dl>\n\n<p>Overrides the core <a class=\"reference internal\" href=\"/es/3.0/ref/django-admin/#django-admin-runserver\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">runserver</span></code></a> command if the <code class=\"docutils literal notranslate\"><span class=\"pre\">staticfiles</span></code> app\nis <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">installed</span></code></a> and adds automatic serving of static\nfiles. File serving doesn’t run through <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-MIDDLEWARE\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">MIDDLEWARE</span></code></a>.</p>\n<p>The command adds these options:</p>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-runserver-nostatic\">\n<span class=\"sig-name descname\"><span class=\"pre\">--nostatic</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-runserver-nostatic\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Use the <code class=\"docutils literal notranslate\"><span class=\"pre\">--nostatic</span></code> option to disable serving of static files with the\n<a class=\"reference internal\" href=\"/es/3.0/ref/contrib/staticfiles/\"><span class=\"doc\">staticfiles</span></a> app entirely. This option is\nonly available if the <a class=\"reference internal\" href=\"/es/3.0/ref/contrib/staticfiles/\"><span class=\"doc\">staticfiles</span></a> app is\nin your project’s <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">INSTALLED_APPS</span></code></a> setting.</p>\n<p>Example usage:</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-5-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</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=\"Shell code\"><code><span class=\"gp\">$ </span>django-admin<span class=\"w\"> </span>runserver<span class=\"w\"> </span>--nostatic\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-5-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</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=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> django-admin runserver --nostatic\n</code></pre></div></div></div>\n<dl class=\"django-admin-option\">\n<dt class=\"sig sig-object\" id=\"cmdoption-runserver-insecure\">\n<span class=\"sig-name descname\"><span class=\"pre\">--insecure</span></span><span class=\"sig-prename descclassname\"></span><a class=\"heading-anchor\" href=\"#cmdoption-runserver-insecure\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Use the <code class=\"docutils literal notranslate\"><span class=\"pre\">--insecure</span></code> option to force serving of static files with the\n<a class=\"reference internal\" href=\"/es/3.0/ref/contrib/staticfiles/\"><span class=\"doc\">staticfiles</span></a> app even if the <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DEBUG</span></code></a>\nsetting is <code class=\"docutils literal notranslate\"><span class=\"pre\">False</span></code>. By using this you acknowledge the fact that it’s\n<strong>grossly inefficient</strong> and probably <strong>insecure</strong>. This is only intended for\nlocal development, should <strong>never be used in production</strong> and is only\navailable if the <a class=\"reference internal\" href=\"/es/3.0/ref/contrib/staticfiles/\"><span class=\"doc\">staticfiles</span></a> app is\nin your project’s <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">INSTALLED_APPS</span></code></a> setting.</p>\n<p><code class=\"docutils literal notranslate\"><span class=\"pre\">--insecure</span></code> doesn’t work with <a class=\"reference internal\" href=\"#django.contrib.staticfiles.storage.ManifestStaticFilesStorage\" title=\"django.contrib.staticfiles.storage.ManifestStaticFilesStorage\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">ManifestStaticFilesStorage</span></code></a>.</p>\n<p>Example usage:</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-6-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</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=\"Shell code\"><code><span class=\"gp\">$ </span>django-admin<span class=\"w\"> </span>runserver<span class=\"w\"> </span>--insecure\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-6-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</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=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> django-admin runserver --insecure\n</code></pre></div></div></div>\n</section>\n</section>\n<section id=\"storages\">\n<span id=\"staticfiles-storages\"></span><h2>Storages<a class=\"heading-anchor\" href=\"#storages\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"staticfilesstorage\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">StaticFilesStorage</span></code><a class=\"heading-anchor\" href=\"#staticfilesstorage\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.staticfiles.storage.StaticFilesStorage\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-prename descclassname\"><span class=\"pre\">storage.</span></span><span class=\"sig-name descname\"><span class=\"pre\">StaticFilesStorage</span></span><a class=\"heading-anchor\" href=\"#django.contrib.staticfiles.storage.StaticFilesStorage\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A subclass of the <a class=\"reference internal\" href=\"/es/3.0/ref/files/storage/#django.core.files.storage.FileSystemStorage\" title=\"django.core.files.storage.FileSystemStorage\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">FileSystemStorage</span></code></a>\nstorage backend that uses the <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATIC_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATIC_ROOT</span></code></a> setting as the base\nfile system location and the <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATIC_URL\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATIC_URL</span></code></a> setting respectively\nas the base URL.</p>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.staticfiles.storage.StaticFilesStorage.post_process\">\n<span class=\"sig-prename descclassname\"><span class=\"pre\">storage.StaticFilesStorage.</span></span><span class=\"sig-name descname\"><span class=\"pre\">post_process</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">paths</span></span></em>, <em class=\"sig-param\"><span class=\"o\"><span class=\"pre\">**</span></span><span class=\"n\"><span class=\"pre\">options</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.contrib.staticfiles.storage.StaticFilesStorage.post_process\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>If this method is defined on a storage, it’s called by the\n<a class=\"reference internal\" href=\"#django-admin-collectstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">collectstatic</span></code></a> management command after each run and gets passed the\nlocal storages and paths of found files as a dictionary, as well as the command\nline options. It yields tuples of three values:\n<code class=\"docutils literal notranslate\"><span class=\"pre\">original_path,</span> <span class=\"pre\">processed_path,</span> <span class=\"pre\">processed</span></code>. The path values are strings and\n<code class=\"docutils literal notranslate\"><span class=\"pre\">processed</span></code> is a boolean indicating whether or not the value was\npost-processed, or an exception if post-processing failed.</p>\n<p>The <a class=\"reference internal\" href=\"#django.contrib.staticfiles.storage.ManifestStaticFilesStorage\" title=\"django.contrib.staticfiles.storage.ManifestStaticFilesStorage\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">ManifestStaticFilesStorage</span></code></a>\nuses this behind the scenes to replace the paths with their hashed\ncounterparts and update the cache appropriately.</p>\n</section>\n<section id=\"manifeststaticfilesstorage\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">ManifestStaticFilesStorage</span></code><a class=\"heading-anchor\" href=\"#manifeststaticfilesstorage\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.staticfiles.storage.ManifestStaticFilesStorage\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-prename descclassname\"><span class=\"pre\">storage.</span></span><span class=\"sig-name descname\"><span class=\"pre\">ManifestStaticFilesStorage</span></span><a class=\"heading-anchor\" href=\"#django.contrib.staticfiles.storage.ManifestStaticFilesStorage\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>A subclass of the <a class=\"reference internal\" href=\"#django.contrib.staticfiles.storage.StaticFilesStorage\" title=\"django.contrib.staticfiles.storage.StaticFilesStorage\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">StaticFilesStorage</span></code></a>\nstorage backend which stores the file names it handles by appending the MD5\nhash of the file’s content to the filename. For example, the file\n<code class=\"docutils literal notranslate\"><span class=\"pre\">css/styles.css</span></code> would also be saved as <code class=\"docutils literal notranslate\"><span class=\"pre\">css/styles.55e7cbb9ba48.css</span></code>.</p>\n<p>The purpose of this storage is to keep serving the old files in case some\npages still refer to those files, e.g. because they are cached by you or\na 3rd party proxy server. Additionally, it’s very helpful if you want to\napply <a class=\"reference external\" href=\"https://developer.yahoo.com/performance/rules.html#expires\">far future Expires headers</a> to the deployed files to speed up the\nload time for subsequent page visits.</p>\n<p>The storage backend automatically replaces the paths found in the saved\nfiles matching other saved files with the path of the cached copy (using\nthe <a class=\"reference internal\" href=\"#django.contrib.staticfiles.storage.StaticFilesStorage.post_process\" title=\"django.contrib.staticfiles.storage.StaticFilesStorage.post_process\"><code class=\"xref py py-meth docutils literal notranslate\"><span class=\"pre\">post_process()</span></code></a>\nmethod). The regular expressions used to find those paths\n(<code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.staticfiles.storage.HashedFilesMixin.patterns</span></code>)\nby default covers the <a class=\"reference external\" href=\"https://www.w3.org/TR/CSS2/cascade.html#at-import\">&#64;import</a> rule and <a class=\"reference external\" href=\"https://www.w3.org/TR/CSS2/syndata.html#uri\">url()</a> statement of <a class=\"reference external\" href=\"https://www.w3.org/Style/CSS/\">Cascading\nStyle Sheets</a>. For example, the <code class=\"docutils literal notranslate\"><span class=\"pre\">'css/styles.css'</span></code> file with the\ncontent</p>\n<div class=\"code-block\" data-language=\"css\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Css</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=\"Css code\"><code><span class=\"p\">@</span><span class=\"k\">import</span><span class=\"w\"> </span><span class=\"nt\">url</span><span class=\"o\">(</span><span class=\"s2\">&quot;../admin/css/base.css&quot;</span><span class=\"o\">)</span><span class=\"p\">;</span>\n</code></pre></div>\n<p>would be replaced by calling the <a class=\"reference internal\" href=\"/es/3.0/ref/files/storage/#django.core.files.storage.Storage.url\" title=\"django.core.files.storage.Storage.url\"><code class=\"xref py py-meth docutils literal notranslate\"><span class=\"pre\">url()</span></code></a>\nmethod of the <code class=\"docutils literal notranslate\"><span class=\"pre\">ManifestStaticFilesStorage</span></code> storage backend, ultimately\nsaving a <code class=\"docutils literal notranslate\"><span class=\"pre\">'css/styles.55e7cbb9ba48.css'</span></code> file with the following\ncontent:</p>\n<div class=\"code-block\" data-language=\"css\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Css</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=\"Css code\"><code><span class=\"p\">@</span><span class=\"k\">import</span><span class=\"w\"> </span><span class=\"nt\">url</span><span class=\"o\">(</span><span class=\"s2\">&quot;../admin/css/base.27e20196a850.css&quot;</span><span class=\"o\">)</span><span class=\"p\">;</span>\n</code></pre></div>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.staticfiles.storage.ManifestStaticFilesStorage.max_post_process_passes\">\n<span class=\"sig-prename descclassname\"><span class=\"pre\">storage.ManifestStaticFilesStorage.</span></span><span class=\"sig-name descname\"><span class=\"pre\">max_post_process_passes</span></span><a class=\"heading-anchor\" href=\"#django.contrib.staticfiles.storage.ManifestStaticFilesStorage.max_post_process_passes\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Since static files might reference other static files that need to have their\npaths replaced, multiple passes of replacing paths may be needed until the file\nhashes converge. To prevent an infinite loop due to hashes not converging (for\nexample, if <code class=\"docutils literal notranslate\"><span class=\"pre\">'foo.css'</span></code> references <code class=\"docutils literal notranslate\"><span class=\"pre\">'bar.css'</span></code> which references\n<code class=\"docutils literal notranslate\"><span class=\"pre\">'foo.css'</span></code>) there is a maximum number of passes before post-processing is\nabandoned. In cases with a large number of references, a higher number of\npasses might be needed. Increase the maximum number of passes by subclassing\n<code class=\"docutils literal notranslate\"><span class=\"pre\">ManifestStaticFilesStorage</span></code> and setting the <code class=\"docutils literal notranslate\"><span class=\"pre\">max_post_process_passes</span></code>\nattribute. It defaults to 5.</p>\n<p>To enable the <code class=\"docutils literal notranslate\"><span class=\"pre\">ManifestStaticFilesStorage</span></code> you have to make sure the\nfollowing requirements are met:</p>\n<ul class=\"simple\">\n<li><p>the <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATICFILES_STORAGE\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATICFILES_STORAGE</span></code></a> setting is set to\n<code class=\"docutils literal notranslate\"><span class=\"pre\">'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'</span></code></p></li>\n<li><p>the <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DEBUG</span></code></a> setting is set to <code class=\"docutils literal notranslate\"><span class=\"pre\">False</span></code></p></li>\n<li><p>you’ve collected all your static files by using the\n<a class=\"reference internal\" href=\"#django-admin-collectstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">collectstatic</span></code></a> management command</p></li>\n</ul>\n<p>Since creating the MD5 hash can be a performance burden to your website\nduring runtime, <code class=\"docutils literal notranslate\"><span class=\"pre\">staticfiles</span></code> will automatically store the mapping with\nhashed names for all processed files in a file called <code class=\"docutils literal notranslate\"><span class=\"pre\">staticfiles.json</span></code>.\nThis happens once when you run the <a class=\"reference internal\" href=\"#django-admin-collectstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">collectstatic</span></code></a> management\ncommand.</p>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.staticfiles.storage.ManifestStaticFilesStorage.manifest_strict\">\n<span class=\"sig-prename descclassname\"><span class=\"pre\">storage.ManifestStaticFilesStorage.</span></span><span class=\"sig-name descname\"><span class=\"pre\">manifest_strict</span></span><a class=\"heading-anchor\" href=\"#django.contrib.staticfiles.storage.ManifestStaticFilesStorage.manifest_strict\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>If a file isn’t found in the <code class=\"docutils literal notranslate\"><span class=\"pre\">staticfiles.json</span></code> manifest at runtime, a\n<code class=\"docutils literal notranslate\"><span class=\"pre\">ValueError</span></code> is raised. This behavior can be disabled by subclassing\n<code class=\"docutils literal notranslate\"><span class=\"pre\">ManifestStaticFilesStorage</span></code> and setting the <code class=\"docutils literal notranslate\"><span class=\"pre\">manifest_strict</span></code> attribute to\n<code class=\"docutils literal notranslate\"><span class=\"pre\">False</span></code> – nonexistent paths will remain unchanged.</p>\n<p>Due to the requirement of running <a class=\"reference internal\" href=\"#django-admin-collectstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">collectstatic</span></code></a>, this storage\ntypically shouldn’t be used when running tests as <code class=\"docutils literal notranslate\"><span class=\"pre\">collectstatic</span></code> isn’t run\nas part of the normal test setup. During testing, ensure that the\n<a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATICFILES_STORAGE\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATICFILES_STORAGE</span></code></a> setting is set to something else like\n<code class=\"docutils literal notranslate\"><span class=\"pre\">'django.contrib.staticfiles.storage.StaticFilesStorage'</span></code> (the default).</p>\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.staticfiles.storage.ManifestStaticFilesStorage.file_hash\">\n<span class=\"sig-prename descclassname\"><span class=\"pre\">storage.ManifestStaticFilesStorage.</span></span><span class=\"sig-name descname\"><span class=\"pre\">file_hash</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">name</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">content</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.contrib.staticfiles.storage.ManifestStaticFilesStorage.file_hash\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>The method that is used when creating the hashed name of a file.\nNeeds to return a hash for the given file name and content.\nBy default it calculates a MD5 hash from the content’s chunks as\nmentioned above. Feel free to override this method to use your own\nhashing algorithm.</p>\n</section>\n<section id=\"cachedstaticfilesstorage\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">CachedStaticFilesStorage</span></code><a class=\"heading-anchor\" href=\"#cachedstaticfilesstorage\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.staticfiles.storage.CachedStaticFilesStorage\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-prename descclassname\"><span class=\"pre\">storage.</span></span><span class=\"sig-name descname\"><span class=\"pre\">CachedStaticFilesStorage</span></span><a class=\"heading-anchor\" href=\"#django.contrib.staticfiles.storage.CachedStaticFilesStorage\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<aside class=\"version-note version-deprecated\" data-version=\"2.2\">\n<p class=\"version-note-title\">Deprecated since Django 2.2</p><p><span class=\"versionmodified deprecated\">Obsoleto desde la versión 2.2: </span><code class=\"docutils literal notranslate\"><span class=\"pre\">CachedStaticFilesStorage</span></code> is deprecated as it has some intractable\nproblems, some of which are outlined below. Use\n<a class=\"reference internal\" href=\"#django.contrib.staticfiles.storage.ManifestStaticFilesStorage\" title=\"django.contrib.staticfiles.storage.ManifestStaticFilesStorage\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">ManifestStaticFilesStorage</span></code></a> or a third-party cloud storage\ninstead.</p>\n</aside>\n<p><code class=\"docutils literal notranslate\"><span class=\"pre\">CachedStaticFilesStorage</span></code> is a similar class like the\n<a class=\"reference internal\" href=\"#django.contrib.staticfiles.storage.ManifestStaticFilesStorage\" title=\"django.contrib.staticfiles.storage.ManifestStaticFilesStorage\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">ManifestStaticFilesStorage</span></code></a> class\nbut uses Django’s <a class=\"reference internal\" href=\"/es/3.0/topics/cache/\"><span class=\"doc\">caching framework</span></a> for storing the\nhashed names of processed files instead of a static manifest file called\n<code class=\"docutils literal notranslate\"><span class=\"pre\">staticfiles.json</span></code>. This is mostly useful for situations in which you don’t\nhave access to the file system.</p>\n<p>If you want to override certain options of the cache backend the storage uses,\nspecify a custom entry in the <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-CACHES\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">CACHES</span></code></a> setting named\n<code class=\"docutils literal notranslate\"><span class=\"pre\">'staticfiles'</span></code>. It falls back to using the <code class=\"docutils literal notranslate\"><span class=\"pre\">'default'</span></code> cache backend.</p>\n<aside class=\"admonition admonition-warning\" role=\"note\">\n<p class=\"admonition-title\">Advertencia</p>\n<p><code class=\"docutils literal notranslate\"><span class=\"pre\">CachedStaticFilesStorage</span></code> isn’t recommended –  in almost all cases\n<code class=\"docutils literal notranslate\"><span class=\"pre\">ManifestStaticFilesStorage</span></code> is a better choice. There are several\nperformance penalties when using <code class=\"docutils literal notranslate\"><span class=\"pre\">CachedStaticFilesStorage</span></code> since a cache\nmiss requires hashing files at runtime. Remote file storage require several\nround-trips to hash a file on a cache miss, as several file accesses are\nrequired to ensure that the file hash is correct in the case of nested file\npaths.</p>\n</aside>\n</section>\n<section id=\"manifestfilesmixin\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">ManifestFilesMixin</span></code><a class=\"heading-anchor\" href=\"#manifestfilesmixin\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.staticfiles.storage.ManifestFilesMixin\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-prename descclassname\"><span class=\"pre\">storage.</span></span><span class=\"sig-name descname\"><span class=\"pre\">ManifestFilesMixin</span></span><a class=\"heading-anchor\" href=\"#django.contrib.staticfiles.storage.ManifestFilesMixin\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Use this mixin with a custom storage to append the MD5 hash of the file’s\ncontent to the filename as <a class=\"reference internal\" href=\"#django.contrib.staticfiles.storage.ManifestStaticFilesStorage\" title=\"django.contrib.staticfiles.storage.ManifestStaticFilesStorage\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">ManifestStaticFilesStorage</span></code></a> does.</p>\n</section>\n</section>\n<section id=\"finders-module\">\n<h2>Finders Module<a class=\"heading-anchor\" href=\"#finders-module\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p><code class=\"docutils literal notranslate\"><span class=\"pre\">staticfiles</span></code> finders has a <code class=\"docutils literal notranslate\"><span class=\"pre\">searched_locations</span></code> attribute which is a list\nof directory paths in which the finders searched. Example usage:</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.contrib.staticfiles</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">finders</span>\n\n<span class=\"n\">result</span> <span class=\"o\">=</span> <span class=\"n\">finders</span><span class=\"o\">.</span><span class=\"n\">find</span><span class=\"p\">(</span><span class=\"s1\">&#39;css/base.css&#39;</span><span class=\"p\">)</span>\n<span class=\"n\">searched_locations</span> <span class=\"o\">=</span> <span class=\"n\">finders</span><span class=\"o\">.</span><span class=\"n\">searched_locations</span>\n</code></pre></div>\n</section>\n<section id=\"other-helpers\">\n<h2>Other Helpers<a class=\"heading-anchor\" href=\"#other-helpers\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>There are a few other helpers outside of the\n<a class=\"reference internal\" href=\"#module-django.contrib.staticfiles\" title=\"django.contrib.staticfiles: An app for handling static files.\"><code class=\"xref py py-mod docutils literal notranslate\"><span class=\"pre\">staticfiles</span></code></a> app to work with static\nfiles:</p>\n<ul class=\"simple\">\n<li><p>The <a class=\"reference internal\" href=\"/es/3.0/ref/templates/api/#django.template.context_processors.static\" title=\"django.template.context_processors.static\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">django.template.context_processors.static()</span></code></a> context processor\nwhich adds <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATIC_URL\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATIC_URL</span></code></a> to every template context rendered\nwith <a class=\"reference internal\" href=\"/es/3.0/ref/templates/api/#django.template.RequestContext\" title=\"django.template.RequestContext\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">RequestContext</span></code></a> contexts.</p></li>\n<li><p>The builtin template tag <a class=\"reference internal\" href=\"/es/3.0/ref/templates/builtins/#std-templatetag-static\"><code class=\"xref std std-ttag docutils literal notranslate\"><span class=\"pre\">static</span></code></a> which takes a path and urljoins it\nwith the static prefix <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATIC_URL\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATIC_URL</span></code></a>. If\n<code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.staticfiles</span></code> is installed, the tag uses the <code class=\"docutils literal notranslate\"><span class=\"pre\">url()</span></code>\nmethod of the <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATICFILES_STORAGE\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATICFILES_STORAGE</span></code></a> instead.</p></li>\n<li><p>The builtin template tag <a class=\"reference internal\" href=\"/es/3.0/ref/templates/builtins/#std-templatetag-get_static_prefix\"><code class=\"xref std std-ttag docutils literal notranslate\"><span class=\"pre\">get_static_prefix</span></code></a> which populates a\ntemplate variable with the static prefix <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATIC_URL\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATIC_URL</span></code></a> to be\nused as a variable or directly.</p></li>\n<li><p>The similar template tag <a class=\"reference internal\" href=\"/es/3.0/ref/templates/builtins/#std-templatetag-get_media_prefix\"><code class=\"xref std std-ttag docutils literal notranslate\"><span class=\"pre\">get_media_prefix</span></code></a> which works like\n<a class=\"reference internal\" href=\"/es/3.0/ref/templates/builtins/#std-templatetag-get_static_prefix\"><code class=\"xref std std-ttag docutils literal notranslate\"><span class=\"pre\">get_static_prefix</span></code></a> but uses <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-MEDIA_URL\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">MEDIA_URL</span></code></a>.</p></li>\n</ul>\n<section id=\"static-file-development-view\">\n<span id=\"staticfiles-development-view\"></span><h3>Static file development view<a class=\"heading-anchor\" href=\"#static-file-development-view\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>The static files tools are mostly designed to help with getting static files\nsuccessfully deployed into production. This usually means a separate,\ndedicated static file server, which is a lot of overhead to mess with when\ndeveloping locally. Thus, the <code class=\"docutils literal notranslate\"><span class=\"pre\">staticfiles</span></code> app ships with a\n<strong>quick and dirty helper view</strong> that you can use to serve files locally in\ndevelopment.</p>\n<dl class=\"py function\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.staticfiles.views.serve\">\n<span class=\"sig-prename descclassname\"><span class=\"pre\">views.</span></span><span class=\"sig-name descname\"><span class=\"pre\">serve</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">request</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">path</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.contrib.staticfiles.views.serve\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>This view function serves static files in development.</p>\n<aside class=\"admonition admonition-warning\" role=\"note\">\n<p class=\"admonition-title\">Advertencia</p>\n<p>This view will only work if <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DEBUG</span></code></a> is <code class=\"docutils literal notranslate\"><span class=\"pre\">True</span></code>.</p>\n<p>That’s because this view is <strong>grossly inefficient</strong> and probably\n<strong>insecure</strong>. This is only intended for local development, and should\n<strong>never be used in production</strong>.</p>\n</aside>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Nota</p>\n<p>To guess the served files” content types, this view relies on the\n<a class=\"reference external\" href=\"https://docs.python.org/3/library/mimetypes.html#module-mimetypes\" title=\"(en Python versión 3.14)\"><code class=\"xref py py-mod docutils literal notranslate\"><span class=\"pre\">mimetypes</span></code></a> module from the Python standard library, which itself\nrelies on the underlying platform’s map files. If you find that this view\ndoesn’t return proper content types for certain files, it is most likely\nthat the platform’s map files need to be updated. This can be achieved, for\nexample, by installing or updating the <code class=\"docutils literal notranslate\"><span class=\"pre\">mailcap</span></code> package on a Red Hat\ndistribution, or <code class=\"docutils literal notranslate\"><span class=\"pre\">mime-support</span></code> on a Debian distribution.</p>\n</aside>\n<p>This view is automatically enabled by <a class=\"reference internal\" href=\"/es/3.0/ref/django-admin/#django-admin-runserver\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">runserver</span></code></a> (with a\n<a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DEBUG</span></code></a> setting set to <code class=\"docutils literal notranslate\"><span class=\"pre\">True</span></code>). To use the view with a different\nlocal development server, add the following snippet to the end of your\nprimary URL configuration:</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.contrib.staticfiles</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">views</span>\n<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\">re_path</span>\n\n<span class=\"k\">if</span> <span class=\"n\">settings</span><span class=\"o\">.</span><span class=\"n\">DEBUG</span><span class=\"p\">:</span>\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=\"s1\">&#39;^static/(?P&lt;path&gt;.*)$&#39;</span><span class=\"p\">,</span> <span class=\"n\">views</span><span class=\"o\">.</span><span class=\"n\">serve</span><span class=\"p\">),</span>\n    <span class=\"p\">]</span>\n</code></pre></div>\n<p>Note, the beginning of the pattern (<code class=\"docutils literal notranslate\"><span class=\"pre\">r'^static/'</span></code>) should be your\n<a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATIC_URL\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATIC_URL</span></code></a> setting.</p>\n<p>Since this is a bit finicky, there’s also a helper function that’ll do this for\nyou:</p>\n<dl class=\"py function\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.staticfiles.urls.staticfiles_urlpatterns\">\n<span class=\"sig-prename descclassname\"><span class=\"pre\">urls.</span></span><span class=\"sig-name descname\"><span class=\"pre\">staticfiles_urlpatterns</span></span><span class=\"sig-paren\">(</span><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.contrib.staticfiles.urls.staticfiles_urlpatterns\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>This will return the proper URL pattern for serving static files to your\nalready defined pattern list. Use it like this:</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.contrib.staticfiles.urls</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">staticfiles_urlpatterns</span>\n\n<span class=\"c1\"># ... the rest of your URLconf here ...</span>\n\n<span class=\"n\">urlpatterns</span> <span class=\"o\">+=</span> <span class=\"n\">staticfiles_urlpatterns</span><span class=\"p\">()</span>\n</code></pre></div>\n<p>This will inspect your <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATIC_URL\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATIC_URL</span></code></a> setting and wire up the view\nto serve static files accordingly. Don’t forget to set the\n<a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATICFILES_DIRS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATICFILES_DIRS</span></code></a> setting appropriately to let\n<code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.staticfiles</span></code> know where to look for files in addition to\nfiles in app directories.</p>\n<aside class=\"admonition admonition-warning\" role=\"note\">\n<p class=\"admonition-title\">Advertencia</p>\n<p>This helper function will only work if <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DEBUG</span></code></a> is <code class=\"docutils literal notranslate\"><span class=\"pre\">True</span></code>\nand your <a class=\"reference internal\" href=\"/es/3.0/ref/settings/#std-setting-STATIC_URL\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">STATIC_URL</span></code></a> setting is neither empty nor a full\nURL such as <code class=\"docutils literal notranslate\"><span class=\"pre\">http://static.example.com/</span></code>.</p>\n<p>That’s because this view is <strong>grossly inefficient</strong> and probably\n<strong>insecure</strong>. This is only intended for local development, and should\n<strong>never be used in production</strong>.</p>\n</aside>\n</section>\n<section id=\"specialized-test-case-to-support-live-testing\">\n<h3>Specialized test case to support “live testing”<a class=\"heading-anchor\" href=\"#specialized-test-case-to-support-live-testing\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.staticfiles.testing.StaticLiveServerTestCase\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-prename descclassname\"><span class=\"pre\">testing.</span></span><span class=\"sig-name descname\"><span class=\"pre\">StaticLiveServerTestCase</span></span><a class=\"heading-anchor\" href=\"#django.contrib.staticfiles.testing.StaticLiveServerTestCase\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>This unittest TestCase subclass extends <a class=\"reference internal\" href=\"/es/3.0/topics/testing/tools/#django.test.LiveServerTestCase\" title=\"django.test.LiveServerTestCase\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">django.test.LiveServerTestCase</span></code></a>.</p>\n<p>Just like its parent, you can use it to write tests that involve running the\ncode under test and consuming it with testing tools through HTTP (e.g. Selenium,\nPhantomJS, etc.), because of which it’s needed that the static assets are also\npublished.</p>\n<p>But given the fact that it makes use of the\n<a class=\"reference internal\" href=\"#django.contrib.staticfiles.views.serve\" title=\"django.contrib.staticfiles.views.serve\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">django.contrib.staticfiles.views.serve()</span></code></a> view described above, it can\ntransparently overlay at test execution-time the assets provided by the\n<code class=\"docutils literal notranslate\"><span class=\"pre\">staticfiles</span></code> finders. This means you don’t need to run\n<a class=\"reference internal\" href=\"#django-admin-collectstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">collectstatic</span></code></a> before or as a part of your tests setup.</p>\n</section>\n</section>","rootId":"module-django.contrib.staticfiles","toc":[{"title":"Settings","anchor":"settings","children":[]},{"title":"Management Commands","anchor":"management-commands","children":[{"title":"collectstatic","anchor":"collectstatic","children":[{"title":"Customizing the ignored pattern list","anchor":"customizing-the-ignored-pattern-list","children":[]}]},{"title":"findstatic","anchor":"findstatic","children":[]},{"title":"runserver","anchor":"runserver","children":[]}]},{"title":"Storages","anchor":"storages","children":[{"title":"StaticFilesStorage","anchor":"staticfilesstorage","children":[]},{"title":"ManifestStaticFilesStorage","anchor":"manifeststaticfilesstorage","children":[]},{"title":"CachedStaticFilesStorage","anchor":"cachedstaticfilesstorage","children":[]},{"title":"ManifestFilesMixin","anchor":"manifestfilesmixin","children":[]}]},{"title":"Finders Module","anchor":"finders-module","children":[]},{"title":"Other Helpers","anchor":"other-helpers","children":[{"title":"Static file development view","anchor":"static-file-development-view","children":[]},{"title":"Specialized test case to support “live testing”","anchor":"specialized-test-case-to-support-live-testing","children":[]}]}],"breadcrumbs":[{"docname":"ref/index","title":"API Reference","url":"/es/3.0/ref/"},{"docname":"ref/contrib/index","title":"contrib packages","url":"/es/3.0/ref/contrib/"}],"prev":{"docname":"ref/contrib/sites","title":"The «sites» framework","url":"/es/3.0/ref/contrib/sites/"},"next":{"docname":"ref/contrib/syndication","title":"The syndication feed framework","url":"/es/3.0/ref/contrib/syndication/"},"formats":{"html":"/es/3.0/ref/contrib/staticfiles/","markdown":"/es/3.0/ref/contrib/staticfiles.md","json":"/es/3.0/ref/contrib/staticfiles.json"},"source":"https://github.com/django/django/blob/stable/3.0.x/docs/ref/contrib/staticfiles.txt","official":"https://docs.djangoproject.com/es/3.0/ref/contrib/staticfiles/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11","1.10","1.9"],"inLocales":["en","zh-hans","fr","ja","id","pt-br","ko","es","el","pl"]}