您有一个在设置中使用STATIC_URL的应用程序。例如:
STATIC_URL = '/static/'
这些在网址模式中:
url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
及其在html中的用法如下:
<img src="{{STATIC_URL}}images/formshare-computer.png" width="497" height="363"/>
如果应用程序在http://mydomin.org/中提供但是如果我在http://mydomin.org/myapp/中提供该应用程序,则此方法有效我需要更改STATIC_URL
有没有办法在没有STATIC_URL的情况下提供静态文件,或者如何在html中正确使用它?
答案 0 :(得分:0)
从模板中的documentation - 使用:
{% load static %}
<img src="{% static 'images/formshare-computer.png' %}" width="497" height="363"/>
MEDIA_ *设置与您的静态内容无关,它们用于管理用户上传的内容。