django 为url指定静态目录
Django文档: https://docs.djangoproject.com/en/1.11/howto/static-files/
python
urlpatterns = [
# ... the rest of your URLconf goes here ...
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns = [
# ... the rest of your URLconf goes here ...
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
例子:
python
{% load static %}
<img src="{% static "my_app/example.jpg" %}" alt="My image"/>
{% load static %}
<img src="{% static "my_app/example.jpg" %}" alt="My image"/>