django之创建第12个项目-加载图片

百度云盘:django之创建第12个项目-加载图片

1、setting配置

#静态文件相关配置
# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/' import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
#os.path.join(BASE_DIR, "static"),
os.path.join(BASE_DIR, "static").replace('\\', '/'),
)

2、设置存放静态文件图片的目录位置

C:\djangoweb\helloworld\blog\static\images\登录按钮1.jpg

3、配置html页面

<!--插入图片-->
<form id="form1" name="form1" method="get" action="http://127.0.0.1:8000/admin/" target="_blank">
<input name="submit" type="image" value="登录入口" src="/static/images/登录按钮1.jpg" />
</form>
上一篇:3.Knockout.Js(属性绑定)


下一篇:css3翻牌效果