{"title":"Aplikasi staticfiles","version":"1.10","locale":"id","docname":"ref/contrib/staticfiles","url":"/id/1.10/ref/contrib/staticfiles/","canonical":"https://djangodocs.dev/id/1.10/ref/contrib/staticfiles/","summary":"django.contrib.staticfiles menyimpan berkas-berkas tetap dari setiap dari aplikasi anda (dan setiap tempat lain anda tentukan) kedalam tempat tunggal yang…","html":"<span id=\"the-staticfiles-app\"></span><h1>Aplikasi <code class=\"docutils literal notranslate\">staticfiles</code><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> menyimpan berkas-berkas tetap dari setiap dari aplikasi anda (dan setiap tempat lain anda tentukan) kedalam tempat tunggal yang dapat dengan mudah dilayani di produksi.</p>\n<aside class=\"admonition admonition-seealso\" role=\"note\">\n<p class=\"admonition-title\">Lihat juga</p>\n<p>Untuk sebuah perkenalaln pada aplikasi berkas-berkas tetap dan beberapa penggunaan contoh, lihat <a class=\"reference internal\" href=\"/id/1.10/howto/static-files/\"><span class=\"doc\">Mengelola berkas statis (sebagai contoh gambar, JavaScript, CSS)</span></a>. Untuk panduan dalam menyebarkan berkas-berkas tetap, lihat <a class=\"reference internal\" href=\"/id/1.10/howto/static-files/deployment/\"><span class=\"doc\">menyebarkan berkas tetap</span></a>.</p>\n</aside>\n<section id=\"settings\">\n<span id=\"staticfiles-settings\"></span><h2>Pengaturan<a class=\"heading-anchor\" href=\"#settings\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Lihat <a class=\"reference internal\" href=\"/id/1.10/ref/settings/#settings-staticfiles\"><span class=\"std std-ref\">staticfiles settings</span></a> untuk rincian pada pengaturan berikut:</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/id/1.10/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=\"/id/1.10/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=\"/id/1.10/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=\"/id/1.10/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=\"/id/1.10/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>Pengelolaan perintah<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> membuka tiga perintah pengelolaan.</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>Kumpulkan berkas-berkas tetap kedalam <a class=\"reference internal\" href=\"/id/1.10/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=\"/id/1.10/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=\"/id/1.10/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=\"/id/1.10/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=\"/id/1.10/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=\"/id/1.10/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.CachedStaticFilesStorage\" title=\"django.contrib.staticfiles.storage.CachedStaticFilesStorage\"><code class=\"xref py py-class docutils literal notranslate\">CachedStaticFilesStorage</code></a>\nby default.</p>\n<p>By default, collected files receive permissions from\n<a class=\"reference internal\" href=\"/id/1.10/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=\"/id/1.10/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>MyStaticFilesStorage<span class=\"p\">,</span> <span class=\"bp\">self</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>Kemudian setel pengaturan <a class=\"reference internal\" href=\"/id/1.10/ref/settings/#std-setting-STATICFILES_STORAGE\"><code class=\"xref std std-setting docutils literal notranslate\">STATICFILES_STORAGE</code></a> menjadi <code class=\"docutils literal notranslate\">'path.to.MyStaticFilesStorage'</code>.</p>\n<p>Beberapa pilihan umum digunakan adalah:</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<aside class=\"version-note version-changed\" data-version=\"1.9\" role=\"note\">\n<p class=\"version-note-title\">Changed in Django 1.9</p><p>Nama lain <code class=\"docutils literal notranslate\">--no-input</code> telah ditambahkan.</p>\n</aside>\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>Abaikan berkas-berkas atau direktori cocok dengan pola gaya-global ini. Gunakan beberapa kali untuk mengabaikan lebih.</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>Lakukan apapun kecuali merubah sistem berkas.</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>Bersihkan berkas-berkas yang ada sebelum mencoba menyalin atau menaut berkas asli.</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>Buat sebuah tautan simbolus pada setiap berkas daripada menyalin.</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>Jangan memanggil metode <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> dari backend penyimpanan <a class=\"reference internal\" href=\"/id/1.10/ref/settings/#std-setting-STATICFILES_STORAGE\"><code class=\"xref std std-setting docutils literal notranslate\">STATICFILES_STORAGE</code></a> yang sudah dikonfigurasi.</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>Jangan abaikan pola-gaya-blobal pribadi umum <code class=\"docutils literal notranslate\">'CVS'</code>, <code class=\"docutils literal notranslate\">'.*'</code> dan <code class=\"docutils literal notranslate\">'*~'</code>.</p>\n</dd></dl>\n\n<p>Untuk daftar penuh dari pilihan, mengacu pada perintah bantuan sendiri dengan menjalankan:</p>\n<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<section id=\"customizing-the-ignored-pattern-list\">\n<span id=\"customize-staticfiles-ignore-patterns\"></span><h4>Menyesuaikan daftar pola diabaikan<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<aside class=\"version-note version-added\" data-version=\"1.10\" role=\"note\">\n<p class=\"version-note-title\">New in Django 1.10</p></aside>\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=\"/id/1.10/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=\"/id/1.10/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=\"python\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python</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=\"Python 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>Mencari untuk satu atau lebih jalur relatif dengan diadakan penemu.</p>\n<p>Sebagai contoh:</p>\n<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<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=\"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<p>This is a debugging aid; it'll show you exactly which static file will be\ncollected for a given path.</p>\n<p>Dengan mengatur bendera <code class=\"docutils literal notranslate\">--verbosity</code> menjadi 0, anda dapat menekan keluaran tambahan dan hanya mendapatkan nama-nama jalur:</p>\n<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<p>Di pihak lain, dengan mengatur bendera <code class=\"docutils literal notranslate\">--verbosity</code> menjadi 2, anda dapat mendapatkan semua direktori yang telah dicari:</p>\n<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</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\" id=\"django-admin-runserver\">\n<span class=\"sig-name descname\">django-admin runserver [addrport]</span><a class=\"heading-anchor\" href=\"#django-admin-runserver\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<p>Overrides the core <a class=\"reference internal\" href=\"/id/1.10/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=\"/id/1.10/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 and the following new 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=\"/id/1.10/ref/contrib/staticfiles/\"><span class=\"doc\">staticfiles</span></a> app entirely. This option is\nonly available if the <a class=\"reference internal\" href=\"/id/1.10/ref/contrib/staticfiles/\"><span class=\"doc\">staticfiles</span></a> app is\nin your project's <a class=\"reference internal\" href=\"/id/1.10/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a> setting.</p>\n<p>Contoh penggunaan:</p>\n<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=\"go\">django-admin runserver --nostatic</span>\n</code></pre></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=\"/id/1.10/ref/contrib/staticfiles/\"><span class=\"doc\">staticfiles</span></a> app even if the <a class=\"reference internal\" href=\"/id/1.10/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=\"/id/1.10/ref/contrib/staticfiles/\"><span class=\"doc\">staticfiles</span></a> app is\nin your project's <a class=\"reference internal\" href=\"/id/1.10/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a> setting. <a class=\"reference internal\" href=\"/id/1.10/ref/django-admin/#django-admin-runserver\"><code class=\"xref std std-djadmin docutils literal notranslate\">runserver</code></a>\n<code class=\"docutils literal notranslate\">--insecure</code> doesn't work with\n<a class=\"reference internal\" href=\"#django.contrib.staticfiles.storage.CachedStaticFilesStorage\" title=\"django.contrib.staticfiles.storage.CachedStaticFilesStorage\"><code class=\"xref py py-class docutils literal notranslate\">CachedStaticFilesStorage</code></a>.</p>\n<p>Contoh penggunaan:</p>\n<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=\"go\">django-admin runserver --insecure</span>\n</code></pre></div>\n</section>\n</section>\n<section id=\"storages\">\n<span id=\"staticfiles-storages\"></span><h2>Penyimpanan<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=\"/id/1.10/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=\"/id/1.10/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=\"/id/1.10/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>This method is called by the <a class=\"reference internal\" href=\"#django-admin-collectstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\">collectstatic</code></a> management command\nafter each run and gets passed the local storages and paths of found\nfiles as a dictionary, as well as the command line options.</p>\n<p>The <a class=\"reference internal\" href=\"#django.contrib.staticfiles.storage.CachedStaticFilesStorage\" title=\"django.contrib.staticfiles.storage.CachedStaticFilesStorage\"><code class=\"xref py py-class docutils literal notranslate\">CachedStaticFilesStorage</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=\"http://www.w3.org/TR/CSS2/cascade.html#at-import\">&#64;import</a> rule and <a class=\"reference external\" href=\"http://www.w3.org/TR/CSS2/syndata.html#uri\">url()</a> statement of <a class=\"reference external\" href=\"http://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+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Css Django</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 Django 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=\"/id/1.10/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+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Css Django</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 Django 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<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=\"/id/1.10/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>Pengaturan <a class=\"reference internal\" href=\"/id/1.10/ref/settings/#std-setting-DEBUG\"><code class=\"xref std std-setting docutils literal notranslate\">DEBUG</code></a> disetel ke <code class=\"docutils literal notranslate\">False</code></p></li>\n<li><p>Anda telah mengumpulkan semua berkas tetap dengan menggunakan perintah pengelolaan <a class=\"reference internal\" href=\"#django-admin-collectstatic\"><code class=\"xref std std-djadmin docutils literal notranslate\">collectstatic</code></a></p></li>\n</ul>\n<aside class=\"version-note version-changed\" data-version=\"1.10\" role=\"note\">\n<p class=\"version-note-title\">Changed in Django 1.10</p><p>In older versions, you also had to use\n<code class=\"docutils literal notranslate\">{% load static from staticfiles %}</code> in your template. The\n<a class=\"reference internal\" href=\"/id/1.10/ref/templates/builtins/#std-templatetag-static\"><code class=\"xref std std-ttag docutils literal notranslate\">static</code></a> template tag (<code class=\"docutils literal notranslate\">{% load static %}</code>) now uses\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\">django.contrib.staticfiles</code></a> if it's installed.</p>\n</aside>\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<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=\"/id/1.10/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=\"cachedstaticfilesstorage\">\n<h3><code class=\"docutils literal notranslate\">CachedStaticFilesStorage</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\">class</span> </em><span class=\"sig-prename descclassname\">storage.</span><span class=\"sig-name descname\">CachedStaticFilesStorage</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<p><code class=\"docutils literal notranslate\">CachedStaticFilesStorage</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\">ManifestStaticFilesStorage</code></a> class\nbut uses Django's <a class=\"reference internal\" href=\"/id/1.10/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\">staticfiles.json</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,\nsimply specify a custom entry in the <a class=\"reference internal\" href=\"/id/1.10/ref/settings/#std-setting-CACHES\"><code class=\"xref std std-setting docutils literal notranslate\">CACHES</code></a> setting named\n<code class=\"docutils literal notranslate\">'staticfiles'</code>. It falls back to using the <code class=\"docutils literal notranslate\">'default'</code> cache backend.</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=\"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=\"go\">from django.contrib.staticfiles import finders</span>\n\n<span class=\"go\">result = finders.find(&#39;css/base.css&#39;)</span>\n<span class=\"go\">searched_locations = finders.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\">staticfiles</code></a> app to work with static\nfiles:</p>\n<ul class=\"simple\">\n<li><p>The <a class=\"reference internal\" href=\"/id/1.10/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=\"/id/1.10/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=\"/id/1.10/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=\"/id/1.10/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=\"/id/1.10/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=\"/id/1.10/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=\"/id/1.10/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=\"/id/1.10/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=\"/id/1.10/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=\"/id/1.10/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=\"/id/1.10/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\">Peringatan</p>\n<p>This view will only work if <a class=\"reference internal\" href=\"/id/1.10/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\">Catatan</p>\n<p>Untuk menebak jenis isi berkas dilayani, tampilan ini bergantung pada modul <a class=\"reference external\" href=\"https://docs.python.org/3/library/mimetypes.html#module-mimetypes\" title=\"(di Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\">mimetypes</code></a> dari pustaka standar Python, yang itu sendiri bergantung pada pokok berkas peta serambi. Jika anda menemukan bahwa tampilan ini tidak mengembalikanjenis isi yang sesuai untuk berkas-berkas tertent, itu kebanyakan sepertinya bahwa berkas-berkas peta serambi butuh diperbaharui. Ini dapat dicapai, sebagai contoh, dengan memasang atau memperbaharui paket <code class=\"docutils literal notranslate\">mailcap</code> pada penyaluran Red Hat, atau <code class=\"docutils literal notranslate\">mime-support</code> pada penyaluran Debian.</p>\n</aside>\n<p>This view is automatically enabled by <a class=\"reference internal\" href=\"/id/1.10/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=\"/id/1.10/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=\"python\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python</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=\"Python 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\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        url<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=\"/id/1.10/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=\"python\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python</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=\"Python 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=\"/id/1.10/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=\"/id/1.10/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\">Peringatan</p>\n<p>This helper function will only work if <a class=\"reference internal\" href=\"/id/1.10/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=\"/id/1.10/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=\"/id/1.10/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":"Pengaturan","anchor":"settings","children":[]},{"title":"Pengelolaan perintah","anchor":"management-commands","children":[{"title":"collectstatic","anchor":"collectstatic","children":[{"title":"Menyesuaikan daftar pola diabaikan","anchor":"customizing-the-ignored-pattern-list","children":[]}]},{"title":"findstatic","anchor":"findstatic","children":[]},{"title":"runserver","anchor":"runserver","children":[]}]},{"title":"Penyimpanan","anchor":"storages","children":[{"title":"StaticFilesStorage","anchor":"staticfilesstorage","children":[]},{"title":"ManifestStaticFilesStorage","anchor":"manifeststaticfilesstorage","children":[]},{"title":"CachedStaticFilesStorage","anchor":"cachedstaticfilesstorage","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":"Acuan API","url":"/id/1.10/ref/"},{"docname":"ref/contrib/index","title":"Paket contrib","url":"/id/1.10/ref/contrib/"}],"prev":{"docname":"ref/contrib/sites","title":"The \"sites\" framework","url":"/id/1.10/ref/contrib/sites/"},"next":{"docname":"ref/contrib/syndication","title":"The syndication feed framework","url":"/id/1.10/ref/contrib/syndication/"},"formats":{"html":"/id/1.10/ref/contrib/staticfiles/","markdown":"/id/1.10/ref/contrib/staticfiles.md","json":"/id/1.10/ref/contrib/staticfiles.json"},"source":"https://github.com/django/django/blob/stable/1.10.x/docs/ref/contrib/staticfiles.txt","official":"https://docs.djangoproject.com/id/1.10/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","fr","ja","id","pt-br","es","el","pl"]}