1.在项目目录下新创建一个app,命名为kingadmin,在templates目录下新建kingadmin目录,用来存放相关页面的模板文件,新建一个templatetags目录,用来存放处理前端模板数据的python函数。

项目/kingadmin/templates/kingadmin/base.html   最基础的模板,存放的js与css

<!DOCTYPE html>
<html lang="zh-CN">
    <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
    <meta name="description" content="">
    <meta name="author" content="">
{#    meta全部保留,IE浏览器相关的可要可不要,图标与css也要全部保留#}
    <link rel="icon" href="http://v3.bootcss.com/favicon.ico">
    <title>王腾的个人站点</title>
    <link href="/static/css/bootstrap.min.css" rel="stylesheet">
    <link href="/static/css/dashboard.css" rel="stylesheet">
     {% block header-resources %} {% endblock %}
{#    这里留一个block块,可以方便其他网页继承时进行扩展 来添加自定义样式#}
  </head>

  <body>
    {% block body %} {% endblock %}
{#     这里留一个block  body块,可以方便其他网页继承时进行扩展 在body里添加自定义的内容#}
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/bootstrap.min.js"></script>
    <script src="/static/js/holder.min.js"></script>
{#    这些js全部保留,js的路径static是settings.py中STATIC_URL = '/static/'对应的STATIC_URL,而不是实际的目录名#}
    <script>
{#        这里是自定义js,点击相应按钮时,按钮变颜色#}
        $(document).ready(function () {
            var current_url = "{{ request.path }}";
            $('.nav-sidebar a[href="{{ request.path }}"]').parent().addClass('active');
        })
    </script>
</body></html>
View Code

相关文章:

  • 2021-12-09
  • 2021-06-25
  • 2022-12-23
  • 2021-11-10
  • 2022-12-23
  • 2021-09-18
  • 2021-07-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-03-09
  • 2022-12-23
  • 2021-09-08
  • 2022-12-23
  • 2021-10-26
  • 2021-07-18
相关资源
相似解决方案