Django中使⽤后台⽹站模板背景:
⼀直想⾃⼰开发⼀个⽹站,但是前端知识⼜不多,好在有模板可以使⽤,下载地址:
开⼲:
环境:
win 10
python 2.7
Django 1.11
pycharm 专业版
⼀、创建Django⼯程:
1.1 按照如下创建Django⼯程
1.2 创建后单击Edit Configurations
打开后输⼊如下,然后单击三⾓箭头,启动服务
1.3 访问⼀下127.0.0.1:8000
⼆、创建应⽤
2.1 在⼯作⽬录下,E:\AutoTestSite,执⾏ python manage.py startapp showcase
2.2 创建应⽤后要在setting中注册该应⽤
三、静态⽂件设置
3.1 在项⽬根⽬录下(与manage.py同级)下创建static路径,将下载的后台模板⽂件引⽤的静态⽂件放进去
3.2 打开项⽬的settings⽂件,在最下⾯添加这么⼀⾏配置,⽤于指定静态⽂件的搜索⽬录:
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
3.3 在showcase⽬录下新建模板⽂件夹:templates,再在templates⽂件夹内创建showcase⽂件夹,该⽂件夹中存放html模板⽂件,最后结构如下
四、编写base.html⽂件
这是⽹站的基础模板⽂件
{% load staticfiles %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit">
{% block title %}
<title>H+ 后台主题UI框架 - 主页</title>
{% endblock %}
<meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中⼼主题,后台HTML,响应式后台">
<meta name="description" content="H+是⼀个完全响应式,基于Bootstrap3最新版本开发的扁平化主题,她采⽤了主流的左右两栏式布局,使⽤了Html5+CSS3等现代技术"> <!--[if lt IE 9]>
<meta http-equiv="refresh" content="0;ie.html" />
<![endif]-->
<link rel="shortcut icon" href="{% static 'favicon.ico' %}"><link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">
<link href="{% static 'css/font-awesome.min.css' %}" rel="stylesheet">
<link href="{% static 'css/animate.css' %}" rel="stylesheet">
<link href="{% static 'css/style.css' %}" rel="stylesheet">
</head>
<body class="fixed-sidebar full-height-layout gray-bg" >
<div id="wrapper">
<!--左侧导航开始-->
<nav class="navbar-default navbar-static-side" role="navigation">
<div class="nav-close"><i class="fa fa-times-circle"></i>
</div>
<div class="sidebar-collapse">
<ul class="nav" id="side-menu">
<li class="nav-header">
<div class="dropdown profile-element">
<span><img alt="image" class="img-circle" src="{% static 'img/profile_small.jpg'%}"/></span>
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
<span class="clear">
<span class="block m-t-xs"><strong class="font-bold">Beaut-zihan</strong></span>
<span class="text-muted text-xs block">超级管理员<b class="caret"></b></span>
</span>
</a>
<ul class="dropdown-menu animated fadeInRight m-t-xs">
<li><a class="J_menuItem" href="form_avatar.html">修改头像</a>
</li>
<li><a class="J_menuItem" href="profile.html">个⼈资料</a>
</li>
<li><a class="J_menuItem" href="contacts.html"></a>
</li>
<li><a class="J_menuItem" href="mailbox.html">信箱</a>
</li>
<li class="divider"></li>
<li><a href="login.html">安全退出</a>
</li>
</ul>
</div>
<div class="logo-element">H+
</div>
</li>
<li>
<a href="#">
<i class="fa fa-home"></i>
<span class="nav-label">主页</span>
<span class="fa arrow"></span>
</a>
<ul class="nav nav-second-level">
<li>
<a class="J_menuItem" href="index_v1.html" data-index="0">主页⽰例⼀</a>
</li>
<li>
<a class="J_menuItem" href="index_v2.html">主页⽰例⼆</a>
</li>
<li>
<a class="J_menuItem" href="index_v3.html">主页⽰例三</a>
</li>
<li>
<a class="J_menuItem" href="index_v4.html">主页⽰例四</a>
</li>
<li>
<a href="index_v5.html" target="_blank">主页⽰例五</a>
</li>
<li>
<a class="J_menuItem" href="/layouts"><i class="fa fa-columns"></i><span class="nav-label">布局</span></a>
</li>
<li>
<a href="#">
<i class="fa fa fa-bar-chart-o"></i>
<span class="nav-label">统计图表</span>
<span class="fa arrow"></span>
</a>
<ul class="nav nav-second-level">
<li>
<a class="J_menuItem" href="graph_echarts.html">百度ECharts</a>
</li>
<li>
<a class="J_menuItem" href="graph_flot.html">Flot</a>
</li>
<li>
<a class="J_menuItem" href="graph_morris.html">Morris.js</a>
</li>
<li>
<a class="J_menuItem" href="graph_rickshaw.html">Rickshaw</a>
</li>
<li>
<a class="J_menuItem" href="graph_peity.html">Peity</a>
</li>
<li>
<a class="J_menuItem" href="graph_sparkline.html">Sparkline</a>
</li>
<li>
<a class="J_menuItem" href="graph_metrics.html">图表组合</a>
</li>
</ul>
</li>
<li>
<a href="mailbox.html"><i class="fa fa-envelope"></i><span class="nav-label">信箱</span><span class="label label-warning pull-right">16</span></a> <ul class="nav nav-second-level">
<li><a class="J_menuItem" href="mailbox.html">收件箱</a>
</li>
<li><a class="J_menuItem" href="mail_detail.html">查看邮件</a>
</li>
<li><a class="J_menuItem" href="mail_compose.html">写信</a>
</li>
</ul>
</li>
<li>
<a href="#"><i class="fa fa-edit"></i><span class="nav-label">表单</span><span class="fa arrow"></span></a>
<ul class="nav nav-second-level">
<li><a class="J_menuItem" href="form_basic.html">基本表单</a>
</li>
<li><a class="J_menuItem" href="form_validate.html">表单验证</a>
</li>
<li><a class="J_menuItem" href="form_advanced.html">⾼级插件</a>
</li>
<li><a class="J_menuItem" href="form_wizard.html">表单向导</a>
</li>
<li>
<a href="#">⽂件上传<span class="fa arrow"></span></a>
<ul class="nav nav-third-level">
<li><a class="J_menuItem" href="form_webuploader.html">百度WebUploader</a>
</li>
<li><a class="J_menuItem" href="form_file_upload.html">DropzoneJS</a>
</li>
<li><a class="J_menuItem" href="form_avatar.html">头像裁剪上传</a>
</li>
</ul>
</li>
<li>
<a href="#">编辑器<span class="fa arrow"></span></a>
<ul class="nav nav-third-level">
<li><a class="J_menuItem" href="form_editors.html">富⽂本编辑器</a>
</li>
<li><a class="J_menuItem" href="form_simditor.html">simditor</a>
</li>
<li><a class="J_menuItem" href="form_markdown.html">MarkDown编辑器</a>
</li>
<li><a class="J_menuItem" href="code_editor.html">代码编辑器</a>
</li>
</ul>
</li>
<li><a class="J_menuItem" href="suggest.html">搜索⾃动补全</a>
</li>
<li><a class="J_menuItem" href="layerdate.html">⽇期选择器layerDate</a>
</li>
</ul>
</li>
<li>
<a href="#"><i class="fa fa-desktop"></i><span class="nav-label">页⾯</span><span class="fa arrow"></span></a>
<ul class="nav nav-second-level">
<li><a class="J_menuItem" href="contacts.html">联系⼈</a>
</li>
<li><a class="J_menuItem" href="profile.html">个⼈资料</a>
</li>
<li>
<a href="#">项⽬管理<span class="fa arrow"></span></a>
<ul class="nav nav-third-level">
<li><a class="J_menuItem" href="projects.html">项⽬</a>
</li>
<li><a class="J_menuItem" href="project_detail.html">项⽬详情</a>
</li>
</ul>
</li>
<li><a class="J_menuItem" href="teams_board.html">团队管理</a>
</li>
<li><a class="J_menuItem" href="social_feed.html">信息流</a>
</li>
<li><a class="J_menuItem" href="clients.html">客户管理</a>
</li>
<li><a class="J_menuItem" href="file_manager.html">⽂件管理器</a>
</li>
<li><a class="J_menuItem" href="calendar.html">⽇历</a>
</li>
<li>
<a href="#">博客<span class="fa arrow"></span></a>
<ul class="nav nav-third-level">
<li><a class="J_menuItem" href="blog.html">⽂章列表</a>
</li>
<li><a class="J_menuItem" href="article.html">⽂章详情</a>
</li>
<li><a class="J_menuItem" href="faq.html">FAQ</a>
</li>
<li>
<a href="#">时间轴<span class="fa arrow"></span></a>
<ul class="nav nav-third-level">
<li><a class="J_menuItem" href="timeline.html">时间轴</a>
</li>
<li><a class="J_menuItem" href="timeline_v2.html">时间轴v2</a>
</li>
</ul>
</li>
<li><a class="J_menuItem" href="pin_board.html">标签墙</a>
</li>
<li>
<a href="#">单据<span class="fa arrow"></span></a>
<ul class="nav nav-third-level">
<li><a class="J_menuItem" href="invoice.html">单据</a>
</li>
<li><a class="J_menuItem" href="invoice_print.html">单据打印</a>
</li>
</ul>
</li>
<li><a class="J_menuItem" href="search_results.html">搜索结果</a>
</li>
<li><a class="J_menuItem" href="forum_main.html">论坛</a>
</li>
<li>
<a href="#">即时通讯<span class="fa arrow"></span></a>
<ul class="nav nav-third-level">
<li><a class="J_menuItem" href="chat_view.html">聊天窗⼝</a>
</li>
<li><a class="J_menuItem" href="webim.html">layIM</a>
</li>
</ul>
</li>
<li>
<a href="#">登录注册相关<span class="fa arrow"></span></a>
<ul class="nav nav-third-level">
<li><a href="login.html" target="_blank">登录页⾯</a>
</li>
<li><a href="login_v2.html" target="_blank">登录页⾯v2</a>
</li>
<li><a href="register.html" target="_blank">注册页⾯</a>
</li>
<li><a href="lockscreen.html" target="_blank">登录超时</a>
</li>
</ul>
</li>
<li><a class="J_menuItem" href="404.html">404页⾯</a>
</li>
<li><a class="J_menuItem" href="500.html">500页⾯</a>
</li>
<li><a class="J_menuItem" href="empty_page.html">空⽩页</a>
</li>
</ul>
</li>
<li>
<a href="#"><i class="fa fa-flask"></i><span class="nav-label">UI元素</span><span class="fa arrow"></span></a> <ul class="nav nav-second-level">
<li><a class="J_menuItem" href="typography.html">排版</a>
</li>
<li>
<a href="#">字体图标<span class="fa arrow"></span></a>
<ul class="nav nav-third-level">
<li>
<a class="J_menuItem" href="fontawesome.html">Font Awesome</a>
</li>
<li>
<a class="J_menuItem" href="glyphicons.html">Glyphicon</a>
</li>
<li>
<a class="J_menuItem" href="iconfont.html">阿⾥巴巴⽮量图标库</a>
</li>
</ul>
</li>
<li>
<a href="#">拖动排序<span class="fa arrow"></span></a>
<ul class="nav nav-third-level">
<li><a class="J_menuItem" href="draggable_panels.html">拖动⾯板</a>
</li>
<li><a class="J_menuItem" href="agile_board.html">任务清单</a>
</li>
</ul>
</li>
<li><a class="J_menuItem" href="buttons.html">按钮</a>
</li>
<li><a class="J_menuItem" href="tabs_panels.html">选项卡&⾯板</a>
</li>
<li><a class="J_menuItem" href="notifications.html">通知&;提⽰</a>
</li>
<li><a class="J_menuItem" href="badges_labels.html">徽章,标签,进度条</a>
</li>
<li>
<a class="J_menuItem" href="grid_options.html">栅格</a>
</li>
<li><a class="J_menuItem" href="plyr.html">视频、⾳频</a>
</li>
<li>
<a href="#">弹框插件<span class="fa arrow"></span></a>
<ul class="nav nav-third-level">
<li><a class="J_menuItem" href="layer.html">Web弹层组件layer</a>
</li>
<li><a class="J_menuItem" href="modal_window.html">模态窗⼝</a>
</li>
<li><a class="J_menuItem" href="sweetalert.html">SweetAlert</a>
</li>
html富文本框</ul>
</li>
<li>
<a href="#">树形视图<span class="fa arrow"></span></a>
<ul class="nav nav-third-level">
<li><a class="J_menuItem" href="jstree.html">jsTree</a>
</li>
<li><a class="J_menuItem" href="tree_view.html">Bootstrap Tree View</a>
</li>
<li><a class="J_menuItem" href="nestable_list.html">nestable</a>
</li>
</ul>
</li>
<li><a class="J_menuItem" href="toastr_notifications.html">Toastr通知</a>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论