{"title":"The staticfiles app","version":"3.2","locale":"ko","docname":"ref/contrib/staticfiles","url":"/ko/3.2/ref/contrib/staticfiles/","canonical":"https://djangodocs.dev/ko/3.2/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…","html":"<span id=\"the-staticfiles-app\"></span><h1>The <code class=\"docutils literal notranslate\">staticfiles</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\">django.contrib.staticfiles</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\" role=\"note\">\n<p class=\"admonition-title\">더 보기</p>\n<p>For an introduction to the static files app and some usage examples, see\n<a class=\"reference internal\" href=\"/ko/3.2/howto/static-files/\"><span class=\"doc\">정적 파일 관리하기(e.g. 이미지, 자바스크립트, CSS)</span></a>. For guidelines on deploying static files,\nsee <a class=\"reference internal\" href=\"/ko/3.2/howto/static-files/deployment/\"><span class=\"doc\">정적 파일 배포하기</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=\"/ko/3.2/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=\"/ko/3.2/ref/settings/#std-setting-STATIC_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\">STATIC_ROOT</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-STATIC_URL\"><code class=\"xref std std-setting docutils literal notranslate\">STATIC_URL</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-STATICFILES_DIRS\"><code class=\"xref std std-setting docutils literal notranslate\">STATICFILES_DIRS</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-STATICFILES_STORAGE\"><code class=\"xref std std-setting docutils literal notranslate\">STATICFILES_STORAGE</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-STATICFILES_FINDERS\"><code class=\"xref std std-setting docutils literal notranslate\">STATICFILES_FINDERS</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\">django.contrib.staticfiles</code> exposes three management commands.</p>\n<section id=\"collectstatic\">\n<h3><code class=\"docutils literal notranslate\">collectstatic</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\">django-admin collectstatic</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=\"/ko/3.2/ref/settings/#std-setting-STATIC_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\">STATIC_ROOT</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\">findstatic</code></a> command\ncan help show you which files are found.</p>\n<p>On subsequent <code class=\"docutils literal notranslate\">collectstatic</code> runs (if <code class=\"docutils literal notranslate\">STATIC_ROOT</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\">STATIC_ROOT</code>. Therefore if you remove an application from\n<a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</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\">collectstatic\n--clear</code></a> option in order to remove stale static files.</p>\n<p>Files are searched by using the <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-STATICFILES_FINDERS\"><code class=\"xref std std-setting docutils literal notranslate\">enabled finders</code></a>. The default is to look in all locations defined in\n<a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-STATICFILES_DIRS\"><code class=\"xref std std-setting docutils literal notranslate\">STATICFILES_DIRS</code></a> and in the <code class=\"docutils literal notranslate\">'static'</code> directory of apps\nspecified by the <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a> setting.</p>\n<p>The <a class=\"reference internal\" href=\"#django-admin-collectstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\">collectstatic</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\">post_process()</code></a>\nmethod of the <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-STATICFILES_STORAGE\"><code class=\"xref std std-setting docutils literal notranslate\">STATICFILES_STORAGE</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\">collectstatic</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\">ManifestStaticFilesStorage</code></a>\nby default.</p>\n<p>By default, collected files receive permissions from\n<a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-FILE_UPLOAD_PERMISSIONS\"><code class=\"xref std std-setting docutils literal notranslate\">FILE_UPLOAD_PERMISSIONS</code></a> and collected directories receive permissions\nfrom <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-FILE_UPLOAD_DIRECTORY_PERMISSIONS\"><code class=\"xref std std-setting docutils literal notranslate\">FILE_UPLOAD_DIRECTORY_PERMISSIONS</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\">file_permissions_mode</code> and/or <code class=\"docutils literal notranslate\">directory_permissions_mode</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=\"nn\">django.contrib.staticfiles</span> <span class=\"kn\">import</span> storage\n\n<span class=\"k\">class</span> <span class=\"nc\">MyStaticFilesStorage</span><span class=\"p\">(</span>storage<span class=\"o\">.</span>StaticFilesStorage<span class=\"p\">):</span>\n    <span class=\"k\">def</span> <span class=\"fm\">__init__</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">,</span> <span class=\"o\">*</span>args<span class=\"p\">,</span> <span class=\"o\">**</span>kwargs<span class=\"p\">):</span>\n        kwargs<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        kwargs<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>args<span class=\"p\">,</span> <span class=\"o\">**</span>kwargs<span class=\"p\">)</span>\n</code></pre></div>\n<p>Then set the <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-STATICFILES_STORAGE\"><code class=\"xref std std-setting docutils literal notranslate\">STATICFILES_STORAGE</code></a> setting to\n<code class=\"docutils literal notranslate\">'path.to.MyStaticFilesStorage'</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\">--noinput</span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\">, </span><span class=\"sig-name descname\">--no-input</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\">--ignore</span><span class=\"sig-prename descclassname\"> PATTERN</span><span class=\"sig-prename descclassname\">, </span><span class=\"sig-name descname\">-i</span><span class=\"sig-prename descclassname\"> PATTERN</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</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\">--dry-run</span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\">, </span><span class=\"sig-name descname\">-n</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\">--clear</span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\">, </span><span class=\"sig-name descname\">-c</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\">--link</span><span class=\"sig-prename descclassname\"></span><span class=\"sig-prename descclassname\">, </span><span class=\"sig-name descname\">-l</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\">--no-post-process</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\">post_process()</code></a>\nmethod of the configured <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-STATICFILES_STORAGE\"><code class=\"xref std std-setting docutils literal notranslate\">STATICFILES_STORAGE</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\">--no-default-ignore</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\">'CVS'</code>, <code class=\"docutils literal notranslate\">'.*'</code>\nand <code class=\"docutils literal notranslate\">'*~'</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 manage.py collectstatic --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\">['CVS', '.*', '*~']</code>, can be customized in\na more persistent way than providing the <code class=\"docutils literal notranslate\">--ignore</code> command option at each\n<code class=\"docutils literal notranslate\">collectstatic</code> invocation. Provide a custom <a class=\"reference internal\" href=\"/ko/3.2/ref/applications/#django.apps.AppConfig\" title=\"django.apps.AppConfig\"><code class=\"xref py py-class docutils literal notranslate\">AppConfig</code></a>\nclass, override the <code class=\"docutils literal notranslate\">ignore_patterns</code> attribute of this class and replace\n<code class=\"docutils literal notranslate\">'django.contrib.staticfiles'</code> with that class path in your\n<a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</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=\"nn\">django.contrib.staticfiles.apps</span> <span class=\"kn\">import</span> StaticFilesConfig\n\n<span class=\"k\">class</span> <span class=\"nc\">MyStaticFilesConfig</span><span class=\"p\">(</span>StaticFilesConfig<span class=\"p\">):</span>\n    ignore_patterns <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\">findstatic</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\">django-admin findstatic staticfile [staticfile ...]</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 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>\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\">findstatic</span><span class=\"sig-prename descclassname\"> --first</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\">--first</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 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>\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\">--verbosity</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 manage.py findstatic css/base.css --verbosity <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\">--verbosity</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 manage.py findstatic css/base.css --verbosity <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\">runserver</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\">django-admin runserver [addrport]</span></dt>\n<dd></dd></dl>\n\n<p>Overrides the core <a class=\"reference internal\" href=\"/ko/3.2/ref/django-admin/#django-admin-runserver\"><code class=\"xref std std-djadmin docutils literal notranslate\">runserver</code></a> command if the <code class=\"docutils literal notranslate\">staticfiles</code> app\nis <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">installed</code></a> and adds automatic serving of static\nfiles. File serving doesn’t run through <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-MIDDLEWARE\"><code class=\"xref std std-setting docutils literal notranslate\">MIDDLEWARE</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\">--nostatic</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\">--nostatic</code> option to disable serving of static files with the\n<a class=\"reference internal\" href=\"/ko/3.2/ref/contrib/staticfiles/\"><span class=\"doc\">staticfiles</span></a> app entirely. This option is\nonly available if the <a class=\"reference internal\" href=\"/ko/3.2/ref/contrib/staticfiles/\"><span class=\"doc\">staticfiles</span></a> app is\nin your project’s <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</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 runserver --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\">--insecure</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\">--insecure</code> option to force serving of static files with the\n<a class=\"reference internal\" href=\"/ko/3.2/ref/contrib/staticfiles/\"><span class=\"doc\">staticfiles</span></a> app even if the <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\">DEBUG</code></a>\nsetting is <code class=\"docutils literal notranslate\">False</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=\"/ko/3.2/ref/contrib/staticfiles/\"><span class=\"doc\">staticfiles</span></a> app is\nin your project’s <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a> setting.</p>\n<p><code class=\"docutils literal notranslate\">--insecure</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\">ManifestStaticFilesStorage</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 runserver --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\">StaticFilesStorage</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\">class</span> </em><span class=\"sig-prename descclassname\">storage.</span><span class=\"sig-name descname\">StaticFilesStorage</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=\"/ko/3.2/ref/files/storage/#django.core.files.storage.FileSystemStorage\" title=\"django.core.files.storage.FileSystemStorage\"><code class=\"xref py py-class docutils literal notranslate\">FileSystemStorage</code></a>\nstorage backend that uses the <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-STATIC_ROOT\"><code class=\"xref std std-setting docutils literal notranslate\">STATIC_ROOT</code></a> setting as the base\nfile system location and the <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-STATIC_URL\"><code class=\"xref std std-setting docutils literal notranslate\">STATIC_URL</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\">storage.StaticFilesStorage.</span><span class=\"sig-name descname\">post_process</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">paths</em>, <em class=\"sig-param\"><span class=\"o\">**</span>options</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\">collectstatic</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\">original_path, processed_path, processed</code>. The path values are strings and\n<code class=\"docutils literal notranslate\">processed</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\">ManifestStaticFilesStorage</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\">ManifestStaticFilesStorage</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\">class</span> </em><span class=\"sig-prename descclassname\">storage.</span><span class=\"sig-name descname\">ManifestStaticFilesStorage</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\">StaticFilesStorage</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\">css/styles.css</code> would also be saved as <code class=\"docutils literal notranslate\">css/styles.55e7cbb9ba48.css</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\">post_process()</code></a>\nmethod). The regular expressions used to find those paths\n(<code class=\"docutils literal notranslate\">django.contrib.staticfiles.storage.HashedFilesMixin.patterns</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\">'css/styles.css'</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=\"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=\"/ko/3.2/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\">url()</code></a>\nmethod of the <code class=\"docutils literal notranslate\">ManifestStaticFilesStorage</code> storage backend, ultimately\nsaving a <code class=\"docutils literal notranslate\">'css/styles.55e7cbb9ba48.css'</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=\"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\">storage.ManifestStaticFilesStorage.</span><span class=\"sig-name descname\">max_post_process_passes</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\">'foo.css'</code> references <code class=\"docutils literal notranslate\">'bar.css'</code> which references\n<code class=\"docutils literal notranslate\">'foo.css'</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\">ManifestStaticFilesStorage</code> and setting the <code class=\"docutils literal notranslate\">max_post_process_passes</code>\nattribute. It defaults to 5.</p>\n<p>To enable the <code class=\"docutils literal notranslate\">ManifestStaticFilesStorage</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=\"/ko/3.2/ref/settings/#std-setting-STATICFILES_STORAGE\"><code class=\"xref std std-setting docutils literal notranslate\">STATICFILES_STORAGE</code></a> setting is set to\n<code class=\"docutils literal notranslate\">'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'</code></p></li>\n<li><p>the <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\">DEBUG</code></a> setting is set to <code class=\"docutils literal notranslate\">False</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\">collectstatic</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\">staticfiles</code> will automatically store the mapping with\nhashed names for all processed files in a file called <code class=\"docutils literal notranslate\">staticfiles.json</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\">collectstatic</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\">storage.ManifestStaticFilesStorage.</span><span class=\"sig-name descname\">manifest_strict</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\">staticfiles.json</code> manifest at runtime, a\n<code class=\"docutils literal notranslate\">ValueError</code> is raised. This behavior can be disabled by subclassing\n<code class=\"docutils literal notranslate\">ManifestStaticFilesStorage</code> and setting the <code class=\"docutils literal notranslate\">manifest_strict</code> attribute to\n<code class=\"docutils literal notranslate\">False</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\">collectstatic</code></a>, this storage\ntypically shouldn’t be used when running tests as <code class=\"docutils literal notranslate\">collectstatic</code> isn’t run\nas part of the normal test setup. During testing, ensure that the\n<a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-STATICFILES_STORAGE\"><code class=\"xref std std-setting docutils literal notranslate\">STATICFILES_STORAGE</code></a> setting is set to something else like\n<code class=\"docutils literal notranslate\">'django.contrib.staticfiles.storage.StaticFilesStorage'</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\">storage.ManifestStaticFilesStorage.</span><span class=\"sig-name descname\">file_hash</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">name</em>, <em class=\"sig-param\">content<span class=\"o\">=</span><span class=\"default_value\">None</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=\"manifestfilesmixin\">\n<h3><code class=\"docutils literal notranslate\">ManifestFilesMixin</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\">class</span> </em><span class=\"sig-prename descclassname\">storage.</span><span class=\"sig-name descname\">ManifestFilesMixin</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\">ManifestStaticFilesStorage</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\">staticfiles</code> finders has a <code class=\"docutils literal notranslate\">searched_locations</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=\"nn\">django.contrib.staticfiles</span> <span class=\"kn\">import</span> finders\n\nresult <span class=\"o\">=</span> finders<span class=\"o\">.</span>find<span class=\"p\">(</span><span class=\"s1\">&#39;css/base.css&#39;</span><span class=\"p\">)</span>\nsearched_locations <span class=\"o\">=</span> finders<span class=\"o\">.</span>searched_locations\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\">staticfiles</code></a> app to work with static\nfiles:</p>\n<ul class=\"simple\">\n<li><p>The <a class=\"reference internal\" href=\"/ko/3.2/ref/templates/api/#django.template.context_processors.static\" title=\"django.template.context_processors.static\"><code class=\"xref py py-func docutils literal notranslate\">django.template.context_processors.static()</code></a> context processor\nwhich adds <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-STATIC_URL\"><code class=\"xref std std-setting docutils literal notranslate\">STATIC_URL</code></a> to every template context rendered\nwith <a class=\"reference internal\" href=\"/ko/3.2/ref/templates/api/#django.template.RequestContext\" title=\"django.template.RequestContext\"><code class=\"xref py py-class docutils literal notranslate\">RequestContext</code></a> contexts.</p></li>\n<li><p>The builtin template tag <a class=\"reference internal\" href=\"/ko/3.2/ref/templates/builtins/#std-templatetag-static\"><code class=\"xref std std-ttag docutils literal notranslate\">static</code></a> which takes a path and urljoins it\nwith the static prefix <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-STATIC_URL\"><code class=\"xref std std-setting docutils literal notranslate\">STATIC_URL</code></a>. If\n<code class=\"docutils literal notranslate\">django.contrib.staticfiles</code> is installed, the tag uses the <code class=\"docutils literal notranslate\">url()</code>\nmethod of the <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-STATICFILES_STORAGE\"><code class=\"xref std std-setting docutils literal notranslate\">STATICFILES_STORAGE</code></a> instead.</p></li>\n<li><p>The builtin template tag <a class=\"reference internal\" href=\"/ko/3.2/ref/templates/builtins/#std-templatetag-get_static_prefix\"><code class=\"xref std std-ttag docutils literal notranslate\">get_static_prefix</code></a> which populates a\ntemplate variable with the static prefix <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-STATIC_URL\"><code class=\"xref std std-setting docutils literal notranslate\">STATIC_URL</code></a> to be\nused as a variable or directly.</p></li>\n<li><p>The similar template tag <a class=\"reference internal\" href=\"/ko/3.2/ref/templates/builtins/#std-templatetag-get_media_prefix\"><code class=\"xref std std-ttag docutils literal notranslate\">get_media_prefix</code></a> which works like\n<a class=\"reference internal\" href=\"/ko/3.2/ref/templates/builtins/#std-templatetag-get_static_prefix\"><code class=\"xref std std-ttag docutils literal notranslate\">get_static_prefix</code></a> but uses <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-MEDIA_URL\"><code class=\"xref std std-setting docutils literal notranslate\">MEDIA_URL</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\">staticfiles</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\">views.</span><span class=\"sig-name descname\">serve</span><span class=\"sig-paren\">(</span><em class=\"sig-param\">request</em>, <em class=\"sig-param\">path</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\">경고</p>\n<p>This view will only work if <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\">DEBUG</code></a> is <code class=\"docutils literal notranslate\">True</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\">참고</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=\"(Python v3.14에서)\"><code class=\"xref py py-mod docutils literal notranslate\">mimetypes</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 are incorrect or need to be updated. This can\nbe achieved, for example, by installing or updating the <code class=\"docutils literal notranslate\">mailcap</code> package\non a Red Hat distribution, <code class=\"docutils literal notranslate\">mime-support</code> on a Debian distribution, or by\nediting the keys under <code class=\"docutils literal notranslate\">HKEY_CLASSES_ROOT</code> in the Windows registry.</p>\n</aside>\n<p>This view is automatically enabled by <a class=\"reference internal\" href=\"/ko/3.2/ref/django-admin/#django-admin-runserver\"><code class=\"xref std std-djadmin docutils literal notranslate\">runserver</code></a> (with a\n<a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\">DEBUG</code></a> setting set to <code class=\"docutils literal notranslate\">True</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=\"nn\">django.conf</span> <span class=\"kn\">import</span> settings\n<span class=\"kn\">from</span> <span class=\"nn\">django.contrib.staticfiles</span> <span class=\"kn\">import</span> views\n<span class=\"kn\">from</span> <span class=\"nn\">django.urls</span> <span class=\"kn\">import</span> re_path\n\n<span class=\"k\">if</span> settings<span class=\"o\">.</span>DEBUG<span class=\"p\">:</span>\n    urlpatterns <span class=\"o\">+=</span> <span class=\"p\">[</span>\n        re_path<span class=\"p\">(</span><span class=\"sa\">r</span><span class=\"s1\">&#39;^static/(?P&lt;path&gt;.*)$&#39;</span><span class=\"p\">,</span> views<span class=\"o\">.</span>serve<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\">r'^static/'</code>) should be your\n<a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-STATIC_URL\"><code class=\"xref std std-setting docutils literal notranslate\">STATIC_URL</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\">urls.</span><span class=\"sig-name descname\">staticfiles_urlpatterns</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=\"nn\">django.contrib.staticfiles.urls</span> <span class=\"kn\">import</span> staticfiles_urlpatterns\n\n<span class=\"c1\"># ... the rest of your URLconf here ...</span>\n\nurlpatterns <span class=\"o\">+=</span> staticfiles_urlpatterns<span class=\"p\">()</span>\n</code></pre></div>\n<p>This will inspect your <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-STATIC_URL\"><code class=\"xref std std-setting docutils literal notranslate\">STATIC_URL</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=\"/ko/3.2/ref/settings/#std-setting-STATICFILES_DIRS\"><code class=\"xref std std-setting docutils literal notranslate\">STATICFILES_DIRS</code></a> setting appropriately to let\n<code class=\"docutils literal notranslate\">django.contrib.staticfiles</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\">경고</p>\n<p>This helper function will only work if <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\">DEBUG</code></a> is <code class=\"docutils literal notranslate\">True</code>\nand your <a class=\"reference internal\" href=\"/ko/3.2/ref/settings/#std-setting-STATIC_URL\"><code class=\"xref std std-setting docutils literal notranslate\">STATIC_URL</code></a> setting is neither empty nor a full\nURL such as <code class=\"docutils literal notranslate\">http://static.example.com/</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\">class</span> </em><span class=\"sig-prename descclassname\">testing.</span><span class=\"sig-name descname\">StaticLiveServerTestCase</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=\"/ko/3.2/topics/testing/tools/#django.test.LiveServerTestCase\" title=\"django.test.LiveServerTestCase\"><code class=\"xref py py-class docutils literal notranslate\">django.test.LiveServerTestCase</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\">django.contrib.staticfiles.views.serve()</code></a> view described above, it can\ntransparently overlay at test execution-time the assets provided by the\n<code class=\"docutils literal notranslate\">staticfiles</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\">collectstatic</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":"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":"/ko/3.2/ref/"},{"docname":"ref/contrib/index","title":"contrib packages","url":"/ko/3.2/ref/contrib/"}],"prev":{"docname":"ref/contrib/sites","title":"The “sites” framework","url":"/ko/3.2/ref/contrib/sites/"},"next":{"docname":"ref/contrib/syndication","title":"The syndication feed framework","url":"/ko/3.2/ref/contrib/syndication/"},"formats":{"html":"/ko/3.2/ref/contrib/staticfiles/","markdown":"/ko/3.2/ref/contrib/staticfiles.md","json":"/ko/3.2/ref/contrib/staticfiles.json"},"source":"https://github.com/django/django/blob/stable/3.2.x/docs/ref/contrib/staticfiles.txt","official":"https://docs.djangoproject.com/ko/3.2/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"],"inLocales":["en","zh-hans","fr","ja","id","it","pt-br","ko","es","el","pl"]}