1. =======================
    
  2. The ``staticfiles`` app
    
  3. =======================
    
  4. 
    
  5. .. module:: django.contrib.staticfiles
    
  6.    :synopsis: An app for handling static files.
    
  7. 
    
  8. ``django.contrib.staticfiles`` collects static files from each of your
    
  9. applications (and any other places you specify) into a single location that
    
  10. can easily be served in production.
    
  11. 
    
  12. .. seealso::
    
  13. 
    
  14.     For an introduction to the static files app and some usage examples, see
    
  15.     :doc:`/howto/static-files/index`. For guidelines on deploying static files,
    
  16.     see :doc:`/howto/static-files/deployment`.
    
  17. 
    
  18. .. _staticfiles-settings:
    
  19. 
    
  20. Settings
    
  21. ========
    
  22. 
    
  23. See :ref:`staticfiles settings <settings-staticfiles>` for details on the
    
  24. following settings:
    
  25. 
    
  26. * :setting:`STATIC_ROOT`
    
  27. * :setting:`STATIC_URL`
    
  28. * :setting:`STATICFILES_DIRS`
    
  29. * :setting:`STATICFILES_STORAGE`
    
  30. * :setting:`STATICFILES_FINDERS`
    
  31. 
    
  32. Management Commands
    
  33. ===================
    
  34. 
    
  35. ``django.contrib.staticfiles`` exposes three management commands.
    
  36. 
    
  37. ``collectstatic``
    
  38. -----------------
    
  39. 
    
  40. .. django-admin:: collectstatic
    
  41. 
    
  42. Collects the static files into :setting:`STATIC_ROOT`.
    
  43. 
    
  44. Duplicate file names are by default resolved in a similar way to how template
    
  45. resolution works: the file that is first found in one of the specified
    
  46. locations will be used. If you're confused, the :djadmin:`findstatic` command
    
  47. can help show you which files are found.
    
  48. 
    
  49. On subsequent ``collectstatic`` runs (if ``STATIC_ROOT`` isn't empty), files
    
  50. are copied only if they have a modified timestamp greater than the timestamp of
    
  51. the file in ``STATIC_ROOT``. Therefore if you remove an application from
    
  52. :setting:`INSTALLED_APPS`, it's a good idea to use the :option:`collectstatic
    
  53. --clear` option in order to remove stale static files.
    
  54. 
    
  55. Files are searched by using the :setting:`enabled finders
    
  56. <STATICFILES_FINDERS>`. The default is to look in all locations defined in
    
  57. :setting:`STATICFILES_DIRS` and in the ``'static'`` directory of apps
    
  58. specified by the :setting:`INSTALLED_APPS` setting.
    
  59. 
    
  60. The :djadmin:`collectstatic` management command calls the
    
  61. :meth:`~django.contrib.staticfiles.storage.StaticFilesStorage.post_process`
    
  62. method of the :setting:`STATICFILES_STORAGE` after each run and passes
    
  63. a list of paths that have been found by the management command. It also
    
  64. receives all command line options of :djadmin:`collectstatic`. This is used
    
  65. by the :class:`~django.contrib.staticfiles.storage.ManifestStaticFilesStorage`
    
  66. by default.
    
  67. 
    
  68. By default, collected files receive permissions from
    
  69. :setting:`FILE_UPLOAD_PERMISSIONS` and collected directories receive permissions
    
  70. from :setting:`FILE_UPLOAD_DIRECTORY_PERMISSIONS`. If you would like different
    
  71. permissions for these files and/or directories, you can subclass either of the
    
  72. :ref:`static files storage classes <staticfiles-storages>` and specify the
    
  73. ``file_permissions_mode`` and/or ``directory_permissions_mode`` parameters,
    
  74. respectively. For example::
    
  75. 
    
  76.     from django.contrib.staticfiles import storage
    
  77. 
    
  78.     class MyStaticFilesStorage(storage.StaticFilesStorage):
    
  79.         def __init__(self, *args, **kwargs):
    
  80.             kwargs['file_permissions_mode'] = 0o640
    
  81.             kwargs['directory_permissions_mode'] = 0o760
    
  82.             super().__init__(*args, **kwargs)
    
  83. 
    
  84. Then set the :setting:`STATICFILES_STORAGE` setting to
    
  85. ``'path.to.MyStaticFilesStorage'``.
    
  86. 
    
  87. Some commonly used options are:
    
  88. 
    
  89. .. django-admin-option:: --noinput, --no-input
    
  90. 
    
  91.     Do NOT prompt the user for input of any kind.
    
  92. 
    
  93. .. django-admin-option:: --ignore PATTERN, -i PATTERN
    
  94. 
    
  95.     Ignore files, directories, or paths matching this glob-style pattern. Use
    
  96.     multiple times to ignore more. When specifying a path, always use forward
    
  97.     slashes, even on Windows.
    
  98. 
    
  99. .. django-admin-option:: --dry-run, -n
    
  100. 
    
  101.     Do everything except modify the filesystem.
    
  102. 
    
  103. .. django-admin-option:: --clear, -c
    
  104. 
    
  105.     Clear the existing files before trying to copy or link the original file.
    
  106. 
    
  107. .. django-admin-option:: --link, -l
    
  108. 
    
  109.     Create a symbolic link to each file instead of copying.
    
  110. 
    
  111. .. django-admin-option:: --no-post-process
    
  112. 
    
  113.     Don't call the
    
  114.     :meth:`~django.contrib.staticfiles.storage.StaticFilesStorage.post_process`
    
  115.     method of the configured :setting:`STATICFILES_STORAGE` storage backend.
    
  116. 
    
  117. .. django-admin-option:: --no-default-ignore
    
  118. 
    
  119.     Don't ignore the common private glob-style patterns ``'CVS'``, ``'.*'``
    
  120.     and ``'*~'``.
    
  121. 
    
  122. For a full list of options, refer to the commands own help by running:
    
  123. 
    
  124. .. console::
    
  125. 
    
  126.    $ python manage.py collectstatic --help
    
  127. 
    
  128. .. _customize-staticfiles-ignore-patterns:
    
  129. 
    
  130. Customizing the ignored pattern list
    
  131. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  132. 
    
  133. The default ignored pattern list, ``['CVS', '.*', '*~']``, can be customized in
    
  134. a more persistent way than providing the ``--ignore`` command option at each
    
  135. ``collectstatic`` invocation. Provide a custom :class:`~django.apps.AppConfig`
    
  136. class, override the ``ignore_patterns`` attribute of this class and replace
    
  137. ``'django.contrib.staticfiles'`` with that class path in your
    
  138. :setting:`INSTALLED_APPS` setting::
    
  139. 
    
  140.     from django.contrib.staticfiles.apps import StaticFilesConfig
    
  141. 
    
  142.     class MyStaticFilesConfig(StaticFilesConfig):
    
  143.         ignore_patterns = [...]  # your custom ignore list
    
  144. 
    
  145. ``findstatic``
    
  146. --------------
    
  147. 
    
  148. .. django-admin:: findstatic staticfile [staticfile ...]
    
  149. 
    
  150. Searches for one or more relative paths with the enabled finders.
    
  151. 
    
  152. For example:
    
  153. 
    
  154. .. console::
    
  155. 
    
  156.    $ python manage.py findstatic css/base.css admin/js/core.js
    
  157.    Found 'css/base.css' here:
    
  158.      /home/special.polls.com/core/static/css/base.css
    
  159.      /home/polls.com/core/static/css/base.css
    
  160.    Found 'admin/js/core.js' here:
    
  161.      /home/polls.com/src/django/contrib/admin/media/js/core.js
    
  162. 
    
  163. .. django-admin-option:: findstatic --first
    
  164. 
    
  165. By default, all matching locations are found. To only return the first match
    
  166. for each relative path, use the ``--first`` option:
    
  167. 
    
  168. .. console::
    
  169. 
    
  170.    $ python manage.py findstatic css/base.css --first
    
  171.    Found 'css/base.css' here:
    
  172.      /home/special.polls.com/core/static/css/base.css
    
  173. 
    
  174. This is a debugging aid; it'll show you exactly which static file will be
    
  175. collected for a given path.
    
  176. 
    
  177. By setting the ``--verbosity`` flag to 0, you can suppress the extra output and
    
  178. just get the path names:
    
  179. 
    
  180. .. console::
    
  181. 
    
  182.    $ python manage.py findstatic css/base.css --verbosity 0
    
  183.    /home/special.polls.com/core/static/css/base.css
    
  184.    /home/polls.com/core/static/css/base.css
    
  185. 
    
  186. On the other hand, by setting the ``--verbosity`` flag to 2, you can get all
    
  187. the directories which were searched:
    
  188. 
    
  189. .. console::
    
  190. 
    
  191.    $ python manage.py findstatic css/base.css --verbosity 2
    
  192.    Found 'css/base.css' here:
    
  193.      /home/special.polls.com/core/static/css/base.css
    
  194.      /home/polls.com/core/static/css/base.css
    
  195.    Looking in the following locations:
    
  196.      /home/special.polls.com/core/static
    
  197.      /home/polls.com/core/static
    
  198.      /some/other/path/static
    
  199. 
    
  200. .. _staticfiles-runserver:
    
  201. 
    
  202. ``runserver``
    
  203. -------------
    
  204. 
    
  205. .. django-admin:: runserver [addrport]
    
  206.     :noindex:
    
  207. 
    
  208. Overrides the core :djadmin:`runserver` command if the ``staticfiles`` app
    
  209. is :setting:`installed<INSTALLED_APPS>` and adds automatic serving of static
    
  210. files. File serving doesn't run through :setting:`MIDDLEWARE`.
    
  211. 
    
  212. The command adds these options:
    
  213. 
    
  214. .. django-admin-option:: --nostatic
    
  215. 
    
  216. Use the ``--nostatic`` option to disable serving of static files with the
    
  217. :doc:`staticfiles </ref/contrib/staticfiles>` app entirely. This option is
    
  218. only available if the :doc:`staticfiles </ref/contrib/staticfiles>` app is
    
  219. in your project's :setting:`INSTALLED_APPS` setting.
    
  220. 
    
  221. Example usage:
    
  222. 
    
  223. .. console::
    
  224. 
    
  225.     $ django-admin runserver --nostatic
    
  226. 
    
  227. .. django-admin-option:: --insecure
    
  228. 
    
  229. Use the ``--insecure`` option to force serving of static files with the
    
  230. :doc:`staticfiles </ref/contrib/staticfiles>` app even if the :setting:`DEBUG`
    
  231. setting is ``False``. By using this you acknowledge the fact that it's
    
  232. **grossly inefficient** and probably **insecure**. This is only intended for
    
  233. local development, should **never be used in production** and is only
    
  234. available if the :doc:`staticfiles </ref/contrib/staticfiles>` app is
    
  235. in your project's :setting:`INSTALLED_APPS` setting.
    
  236. 
    
  237. ``--insecure`` doesn't work with :class:`~.storage.ManifestStaticFilesStorage`.
    
  238. 
    
  239. Example usage:
    
  240. 
    
  241. .. console::
    
  242. 
    
  243.     $ django-admin runserver --insecure
    
  244. 
    
  245. .. _staticfiles-storages:
    
  246. 
    
  247. Storages
    
  248. ========
    
  249. 
    
  250. ``StaticFilesStorage``
    
  251. ----------------------
    
  252. 
    
  253. .. class:: storage.StaticFilesStorage
    
  254. 
    
  255. A subclass of the :class:`~django.core.files.storage.FileSystemStorage`
    
  256. storage backend that uses the :setting:`STATIC_ROOT` setting as the base
    
  257. file system location and the :setting:`STATIC_URL` setting respectively
    
  258. as the base URL.
    
  259. 
    
  260. .. method:: storage.StaticFilesStorage.post_process(paths, **options)
    
  261. 
    
  262. If this method is defined on a storage, it's called by the
    
  263. :djadmin:`collectstatic` management command after each run and gets passed the
    
  264. local storages and paths of found files as a dictionary, as well as the command
    
  265. line options. It yields tuples of three values:
    
  266. ``original_path, processed_path, processed``. The path values are strings and
    
  267. ``processed`` is a boolean indicating whether or not the value was
    
  268. post-processed, or an exception if post-processing failed.
    
  269. 
    
  270. The :class:`~django.contrib.staticfiles.storage.ManifestStaticFilesStorage`
    
  271. uses this behind the scenes to replace the paths with their hashed
    
  272. counterparts and update the cache appropriately.
    
  273. 
    
  274. ``ManifestStaticFilesStorage``
    
  275. ------------------------------
    
  276. 
    
  277. .. class:: storage.ManifestStaticFilesStorage
    
  278. 
    
  279. A subclass of the :class:`~django.contrib.staticfiles.storage.StaticFilesStorage`
    
  280. storage backend which stores the file names it handles by appending the MD5
    
  281. hash of the file's content to the filename. For example, the file
    
  282. ``css/styles.css`` would also be saved as ``css/styles.55e7cbb9ba48.css``.
    
  283. 
    
  284. The purpose of this storage is to keep serving the old files in case some
    
  285. pages still refer to those files, e.g. because they are cached by you or
    
  286. a 3rd party proxy server. Additionally, it's very helpful if you want to
    
  287. apply `far future Expires headers`_ to the deployed files to speed up the
    
  288. load time for subsequent page visits.
    
  289. 
    
  290. The storage backend automatically replaces the paths found in the saved
    
  291. files matching other saved files with the path of the cached copy (using
    
  292. the :meth:`~django.contrib.staticfiles.storage.StaticFilesStorage.post_process`
    
  293. method). The regular expressions used to find those paths
    
  294. (``django.contrib.staticfiles.storage.HashedFilesMixin.patterns``) cover:
    
  295. 
    
  296. * The `@import`_ rule and `url()`_ statement of `Cascading Style Sheets`_.
    
  297. * `Source map`_ comments in CSS and JavaScript files.
    
  298. 
    
  299. For example, the ``'css/styles.css'`` file with this content:
    
  300. 
    
  301. .. code-block:: css
    
  302. 
    
  303.     @import url("../admin/css/base.css");
    
  304. 
    
  305. ...would be replaced by calling the
    
  306. :meth:`~django.core.files.storage.Storage.url` method of the
    
  307. ``ManifestStaticFilesStorage`` storage backend, ultimately saving a
    
  308. ``'css/styles.55e7cbb9ba48.css'`` file with the following content:
    
  309. 
    
  310. .. code-block:: css
    
  311. 
    
  312.     @import url("../admin/css/base.27e20196a850.css");
    
  313. 
    
  314. You can change the location of the manifest file by using a custom
    
  315. ``ManifestStaticFilesStorage`` subclass that sets the ``manifest_storage``
    
  316. argument. For example::
    
  317. 
    
  318.     from django.conf import settings
    
  319.     from django.contrib.staticfiles.storage import (
    
  320.         ManifestStaticFilesStorage, StaticFilesStorage,
    
  321.     )
    
  322. 
    
  323.     class MyManifestStaticFilesStorage(ManifestStaticFilesStorage):
    
  324.         def __init__(self, *args, **kwargs):
    
  325.             manifest_storage = StaticFilesStorage(location=settings.BASE_DIR)
    
  326.             super().__init__(*args, manifest_storage=manifest_storage, **kwargs)
    
  327. 
    
  328. .. admonition:: References in comments
    
  329. 
    
  330.     ``ManifestStaticFilesStorage`` doesn't ignore paths in statements that are
    
  331.     commented out. This :ticket:`may crash on the nonexistent paths <21080>`.
    
  332.     You should check and eventually strip comments.
    
  333. 
    
  334. .. versionchanged:: 4.0
    
  335. 
    
  336.     Support for finding paths in JavaScript source map comments was added.
    
  337. 
    
  338.     The ``manifest_storage`` argument was added.
    
  339. 
    
  340. .. versionchanged:: 4.1
    
  341. 
    
  342.     Support for finding paths in CSS source map comments was added.
    
  343. 
    
  344. .. attribute:: storage.ManifestStaticFilesStorage.max_post_process_passes
    
  345. 
    
  346. Since static files might reference other static files that need to have their
    
  347. paths replaced, multiple passes of replacing paths may be needed until the file
    
  348. hashes converge. To prevent an infinite loop due to hashes not converging (for
    
  349. example, if ``'foo.css'`` references ``'bar.css'`` which references
    
  350. ``'foo.css'``) there is a maximum number of passes before post-processing is
    
  351. abandoned. In cases with a large number of references, a higher number of
    
  352. passes might be needed. Increase the maximum number of passes by subclassing
    
  353. ``ManifestStaticFilesStorage`` and setting the ``max_post_process_passes``
    
  354. attribute. It defaults to 5.
    
  355. 
    
  356. To enable the ``ManifestStaticFilesStorage`` you have to make sure the
    
  357. following requirements are met:
    
  358. 
    
  359. * the :setting:`STATICFILES_STORAGE` setting is set to
    
  360.   ``'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'``
    
  361. * the :setting:`DEBUG` setting is set to ``False``
    
  362. * you've collected all your static files by using the
    
  363.   :djadmin:`collectstatic` management command
    
  364. 
    
  365. Since creating the MD5 hash can be a performance burden to your website
    
  366. during runtime, ``staticfiles`` will automatically store the mapping with
    
  367. hashed names for all processed files in a file called ``staticfiles.json``.
    
  368. This happens once when you run the :djadmin:`collectstatic` management
    
  369. command.
    
  370. 
    
  371. .. attribute:: storage.ManifestStaticFilesStorage.manifest_strict
    
  372. 
    
  373. If a file isn't found in the ``staticfiles.json`` manifest at runtime, a
    
  374. ``ValueError`` is raised. This behavior can be disabled by subclassing
    
  375. ``ManifestStaticFilesStorage`` and setting the ``manifest_strict`` attribute to
    
  376. ``False`` -- nonexistent paths will remain unchanged.
    
  377. 
    
  378. Due to the requirement of running :djadmin:`collectstatic`, this storage
    
  379. typically shouldn't be used when running tests as ``collectstatic`` isn't run
    
  380. as part of the normal test setup. During testing, ensure that the
    
  381. :setting:`STATICFILES_STORAGE` setting is set to something else like
    
  382. ``'django.contrib.staticfiles.storage.StaticFilesStorage'`` (the default).
    
  383. 
    
  384. .. method:: storage.ManifestStaticFilesStorage.file_hash(name, content=None)
    
  385. 
    
  386. The method that is used when creating the hashed name of a file.
    
  387. Needs to return a hash for the given file name and content.
    
  388. By default it calculates a MD5 hash from the content's chunks as
    
  389. mentioned above. Feel free to override this method to use your own
    
  390. hashing algorithm.
    
  391. 
    
  392. .. _`far future Expires headers`: https://developer.yahoo.com/performance/rules.html#expires
    
  393. .. _`@import`: https://www.w3.org/TR/CSS2/cascade.html#at-import
    
  394. .. _`url()`: https://www.w3.org/TR/CSS2/syndata.html#uri
    
  395. .. _`Cascading Style Sheets`: https://www.w3.org/Style/CSS/
    
  396. .. _`source map`: https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Use_a_source_map
    
  397. 
    
  398. ``ManifestFilesMixin``
    
  399. ----------------------
    
  400. 
    
  401. .. class:: storage.ManifestFilesMixin
    
  402. 
    
  403. Use this mixin with a custom storage to append the MD5 hash of the file's
    
  404. content to the filename as :class:`~storage.ManifestStaticFilesStorage` does.
    
  405. 
    
  406. .. versionchanged:: 4.0
    
  407. 
    
  408.     The ``manifest_storage`` argument was added.
    
  409. 
    
  410. Finders Module
    
  411. ==============
    
  412. 
    
  413. ``staticfiles`` finders has a ``searched_locations`` attribute which is a list
    
  414. of directory paths in which the finders searched. Example usage::
    
  415. 
    
  416.     from django.contrib.staticfiles import finders
    
  417. 
    
  418.     result = finders.find('css/base.css')
    
  419.     searched_locations = finders.searched_locations
    
  420. 
    
  421. Other Helpers
    
  422. =============
    
  423. 
    
  424. There are a few other helpers outside of the
    
  425. :mod:`staticfiles <django.contrib.staticfiles>` app to work with static
    
  426. files:
    
  427. 
    
  428. - The :func:`django.template.context_processors.static` context processor
    
  429.   which adds :setting:`STATIC_URL` to every template context rendered
    
  430.   with :class:`~django.template.RequestContext` contexts.
    
  431. 
    
  432. - The builtin template tag :ttag:`static` which takes a path and urljoins it
    
  433.   with the static prefix :setting:`STATIC_URL`. If
    
  434.   ``django.contrib.staticfiles`` is installed, the tag uses the ``url()``
    
  435.   method of the :setting:`STATICFILES_STORAGE` instead.
    
  436. 
    
  437. - The builtin template tag :ttag:`get_static_prefix` which populates a
    
  438.   template variable with the static prefix :setting:`STATIC_URL` to be
    
  439.   used as a variable or directly.
    
  440. 
    
  441. - The similar template tag :ttag:`get_media_prefix` which works like
    
  442.   :ttag:`get_static_prefix` but uses :setting:`MEDIA_URL`.
    
  443. 
    
  444. .. _staticfiles-development-view:
    
  445. 
    
  446. Static file development view
    
  447. ----------------------------
    
  448. 
    
  449. .. currentmodule:: django.contrib.staticfiles
    
  450. 
    
  451. The static files tools are mostly designed to help with getting static files
    
  452. successfully deployed into production. This usually means a separate,
    
  453. dedicated static file server, which is a lot of overhead to mess with when
    
  454. developing locally. Thus, the ``staticfiles`` app ships with a
    
  455. **quick and dirty helper view** that you can use to serve files locally in
    
  456. development.
    
  457. 
    
  458. .. function:: views.serve(request, path)
    
  459. 
    
  460. This view function serves static files in development.
    
  461. 
    
  462. .. warning::
    
  463. 
    
  464.     This view will only work if :setting:`DEBUG` is ``True``.
    
  465. 
    
  466.     That's because this view is **grossly inefficient** and probably
    
  467.     **insecure**. This is only intended for local development, and should
    
  468.     **never be used in production**.
    
  469. 
    
  470. .. note::
    
  471. 
    
  472.     To guess the served files' content types, this view relies on the
    
  473.     :py:mod:`mimetypes` module from the Python standard library, which itself
    
  474.     relies on the underlying platform's map files. If you find that this view
    
  475.     doesn't return proper content types for certain files, it is most likely
    
  476.     that the platform's map files are incorrect or need to be updated. This can
    
  477.     be achieved, for example, by installing or updating the ``mailcap`` package
    
  478.     on a Red Hat distribution, ``mime-support`` on a Debian distribution, or by
    
  479.     editing the keys under ``HKEY_CLASSES_ROOT`` in the Windows registry.
    
  480. 
    
  481. This view is automatically enabled by :djadmin:`runserver` (with a
    
  482. :setting:`DEBUG` setting set to ``True``). To use the view with a different
    
  483. local development server, add the following snippet to the end of your
    
  484. primary URL configuration::
    
  485. 
    
  486.    from django.conf import settings
    
  487.    from django.contrib.staticfiles import views
    
  488.    from django.urls import re_path
    
  489. 
    
  490.    if settings.DEBUG:
    
  491.        urlpatterns += [
    
  492.            re_path(r'^static/(?P<path>.*)$', views.serve),
    
  493.        ]
    
  494. 
    
  495. Note, the beginning of the pattern (``r'^static/'``) should be your
    
  496. :setting:`STATIC_URL` setting.
    
  497. 
    
  498. Since this is a bit finicky, there's also a helper function that'll do this for
    
  499. you:
    
  500. 
    
  501. .. function:: urls.staticfiles_urlpatterns()
    
  502. 
    
  503. This will return the proper URL pattern for serving static files to your
    
  504. already defined pattern list. Use it like this::
    
  505. 
    
  506.    from django.contrib.staticfiles.urls import staticfiles_urlpatterns
    
  507. 
    
  508.    # ... the rest of your URLconf here ...
    
  509. 
    
  510.    urlpatterns += staticfiles_urlpatterns()
    
  511. 
    
  512. This will inspect your :setting:`STATIC_URL` setting and wire up the view
    
  513. to serve static files accordingly. Don't forget to set the
    
  514. :setting:`STATICFILES_DIRS` setting appropriately to let
    
  515. ``django.contrib.staticfiles`` know where to look for files in addition to
    
  516. files in app directories.
    
  517. 
    
  518. .. warning::
    
  519. 
    
  520.     This helper function will only work if :setting:`DEBUG` is ``True``
    
  521.     and your :setting:`STATIC_URL` setting is neither empty nor a full
    
  522.     URL such as ``http://static.example.com/``.
    
  523. 
    
  524.     That's because this view is **grossly inefficient** and probably
    
  525.     **insecure**. This is only intended for local development, and should
    
  526.     **never be used in production**.
    
  527. 
    
  528. Specialized test case to support 'live testing'
    
  529. -----------------------------------------------
    
  530. 
    
  531. .. class:: testing.StaticLiveServerTestCase
    
  532. 
    
  533. This unittest TestCase subclass extends :class:`django.test.LiveServerTestCase`.
    
  534. 
    
  535. Just like its parent, you can use it to write tests that involve running the
    
  536. code under test and consuming it with testing tools through HTTP (e.g. Selenium,
    
  537. PhantomJS, etc.), because of which it's needed that the static assets are also
    
  538. published.
    
  539. 
    
  540. But given the fact that it makes use of the
    
  541. :func:`django.contrib.staticfiles.views.serve` view described above, it can
    
  542. transparently overlay at test execution-time the assets provided by the
    
  543. ``staticfiles`` finders. This means you don't need to run
    
  544. :djadmin:`collectstatic` before or as a part of your tests setup.