• 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:djangowebhelloworldlogstaticimages登录按钮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>
  • 相关阅读:
    Json2JsonArray JsonArray2StringArray
    循环结构
    类型转换代码
    字符串的截取拼接
    循环语句,选择结构的相关代码
    Java代码2-运算符简单运用
    Java代码1
    集合框架
    接口
    继承多态
  • 原文地址:https://www.cnblogs.com/dengyg200891/p/5358784.html
Copyright © 2020-2023  润新知