我想显示静态图像和CSS文件
settings.py
STATIC_PATH = os.path.join(BASE_DIR,'static') STATIC_URL = '/static/' STATICFILES_DIRS = ( BASE_DIR +"/articles/static",) STATIC_ROOT = os.path.join(BASE_DIR,"static",)在模板中我正在尝试显示img文件夹中的图像
article.html
{% load staticfiles %} <img src = "{% static '/img/default-by.gif' %}" alt = "left slide"/>文件夹结构
根据django docs我尝试访问静态图像的文件夹结构https://docs.djangoproject.com/en/1.9/intro/tutorial06/文件夹结构
NewsArticles -->articles --> static -->articles -->img -->default-by.gif db.sqlite3 manage.py media NewsArticles README.md static templates我正在使用firebug检查其显示的图像位置,如提到的http://127.0.0.1:8000/static/img/default-by.gif
I want to display static images and CSS file
settings.py
STATIC_PATH = os.path.join(BASE_DIR,'static') STATIC_URL = '/static/' STATICFILES_DIRS = ( BASE_DIR +"/articles/static",) STATIC_ROOT = os.path.join(BASE_DIR,"static",)In Template I am trying display the images from img folder
article.html
{% load staticfiles %} <img src = "{% static '/img/default-by.gif' %}" alt = "left slide"/>Folder Structure
The folder structure where I have tried to access static images according to the django docs https://docs.djangoproject.com/en/1.9/intro/tutorial06/ Folder Structure
NewsArticles -->articles --> static -->articles -->img -->default-by.gif db.sqlite3 manage.py media NewsArticles README.md static templatesI am using firebug to check the image location its showing as mentioned http://127.0.0.1:8000/static/img/default-by.gif
最满意答案
你为你的形象提供了错误的道路。 它应该是这样的
{% load staticfiles %} <img src = "{% static 'articles/img/default-by.gif' %}" alt = "left slide"/>希望这会奏效。
You are giving wrong path for your image. It should be like this
{% load staticfiles %} <img src = "{% static 'articles/img/default-by.gif' %}" alt = "left slide"/>Hope this will works.
更多推荐
static,img,图像,文件夹,电脑培训,计算机培训,IT培训"/> <meta name="description
发布评论