mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #21221 -- Made form Media and static template tag use staticfiles if installed.
This commit is contained in:
parent
6be9589eb3
commit
cf546e11ac
34 changed files with 145 additions and 144 deletions
|
@ -19,17 +19,17 @@ Configuring static files
|
|||
STATIC_URL = '/static/'
|
||||
|
||||
3. In your templates, either hardcode the url like
|
||||
``/static/my_app/myexample.jpg`` or, preferably, use the
|
||||
:ttag:`static<staticfiles-static>` template tag to build the URL for the given
|
||||
relative path by using the configured :setting:`STATICFILES_STORAGE` storage
|
||||
(this makes it much easier when you want to switch to a content delivery
|
||||
network (CDN) for serving static files).
|
||||
``/static/my_app/myexample.jpg`` or, preferably, use the :ttag:`static`
|
||||
template tag to build the URL for the given relative path by using the
|
||||
configured :setting:`STATICFILES_STORAGE` storage (this makes it much easier
|
||||
when you want to switch to a content delivery network (CDN) for serving
|
||||
static files).
|
||||
|
||||
.. _staticfiles-in-templates:
|
||||
|
||||
.. code-block:: html+django
|
||||
|
||||
{% load staticfiles %}
|
||||
{% load static %}
|
||||
<img src="{% static "my_app/myexample.jpg" %}" alt="My image"/>
|
||||
|
||||
4. Store your static files in a folder called ``static`` in your app. For
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue