赞
踩
(1)创建项目
>django-admin startproject crm
(2)进入crm目录,运行服务
>cd crm
crm>python manage.py runserver
(3)创建一个app
crm>python manage.py startapp accounts
添加app
(4)在settings里设置中文支持和时区
(1)在accounts目录下创建一个urls文件夹,存放网页路径
(2)添加views
(3)添加urls
(4)配置全局urls
(5)再次运行服务
(1)创建模板文件夹
在dashboard.html里写入
(2)使用模板文件
在views.py里更改
打开浏览器
对其他两个页面进行同样操作
(3)创建公用模板文件
在dashboard.html文件里做如下更改
其他两个文件做同样处理,打开浏览器
创建一个navbar.html文件,作为公用的导航条
在main.html文件里做如下更改
(4)搭建界面,美化网页
模板中涉及到的html文件如下,status用来显示订单状态
main.html
<!DOCTYPE html> <html> <head> <title>CRM</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <style> #logo{ } body{ background-color: #ebeff5; } #total-orders{ background-color: #4cb4c7; } #orders-delivered{ background-color: #7abecc; } #orders-pending{ background-color: #7CD1C0; } </style> </head> <body> {% include 'accounts/navbar.html' %} <div class="container-fluid"> {% block content %} {% endblock %} </div> <hr> <h5>Our footer</h5> </body> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> </html>
navbar.html
<nav class="navbar navbar-expand-lg navbar-dark bg-dark"> <a class="navbar-brand" href="#">Navbar</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarNav"> <ul class="navbar-nav"> <li class="nav-item active"> <a class="nav-link" href="#">Dashboard</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Products</a> </li> </ul> </div> </nav>
dashboard.html
{% extends 'accounts/main.html' %} {% block content %} {% include 'accounts/status.html' %} <br> <div class="row"> <div class="col-md-5"> <h5>CUSTOMERS:</h5> <hr> <div class="card card-body"> <a class="btn btn-primary btn-sm btn-block" href="">Create Customer</a> <table class="table table-sm"> <tr> <th></th> <th>Customer</th> <th>Orders</th> </tr> </table> </div> </div> <div class="col-md-7"> <h5>LAST 5 ORDERS</h5> <hr> <div class="card card-body"> <a class="btn btn-primary btn-sm btn-block" href="">Create Order</a> <table class="table table-sm"> <tr> <th>Product</th> <th>Date Orderd</th> <th>Status</th> <th>Update</th> <th>Remove</th> </tr> </table> </div> </div> </div> {% endblock %}
products.html
{% extends 'accounts/main.html' %} {% block content %} <br> <div class="row"> <div class="col-md"> <div class="card card-body"> <h5>Products</h5> </div> <div class="card card-body"> <table class="table"> <tr> <th>Product</th> <th>Category</th> <th>Price</th> </tr> </table> </div> </div> </div> {% endblock content %}
customer.html
{% extends 'accounts/main.html' %} {% block content %} <br> <div class="row"> <div class="col-md"> <div class="card card-body"> <h5>Customer:</h5> <hr> <a class="btn btn-outline-info btn-sm btn-block" href="">Update Customer</a> <a class="btn btn-outline-danger btn-sm btn-block" href="">Delete Customer</a> </div> </div> <div class="col-md"> <div class="card card-body"> <h5>Contact Information</h5> <hr> <p>Email: </p> <p>Phone: </p> </div> </div> <div class="col-md"> <div class="card card-body"> <h5>Total Orders</h5> <hr> <h1 style="text-align: center;padding: 10px"></h1> </div> </div> </div> <br> <div class="row"> <div class="col"> <div class="card card-body"> <form method="get"> <button class="btn btn-primary" type="submit">Search</button> </form> </div> </div> </div> <br> <div class="row"> <div class="col-md"> <div class="card card-body"> <table class="table table-sm"> <tr> <th>Product</th> <th>Category</th> <th>Date Orderd</th> <th>Status</th> <th>Update</th> <th>Remove</th> </tr> </table> </div> </div> </div> {% endblock %}
status.html
<br> <div class="row"> <div class="col"> <div class="col-md"> <div class="card text-center text-white mb-3" id="total-orders"> <div class="card-header"> <h5 class="card-title">Total Orders</h5> </div> <div class="card-body"> <h3 class="card-title"></h3> </div> </div> </div> </div> <div class="col"> <div class="col-md"> <div class="card text-center text-white mb-3" id="orders-delivered"> <div class="card-header"> <h5 class="card-title">Orders Delivered</h5> </div> <div class="card-body"> <h3 class="card-title"></h3> </div> </div> </div> </div> <div class="col"> <div class="col-md"> <div class="card text-center text-white mb-3" id="orders-pending"> <div class="card-header"> <h5 class="card-title">Orders Pending</h5> </div> <div class="card-body"> <h3 class="card-title"></h3> </div> </div> </div> </div> </div>
(1)创建文件夹,将main.html文件中的css代码复制到main.css中
(2)在settings中设置static文件夹路径
(3)在main.html文件中加载static文件
(4)设置图标
在settings中设置图标路径
在navbar.html文件中导入
教程链接:https://www.youtube.com/watch?v=mOu9fpfzyUg&list=PL-51WBLyFTg2vW-_6XBoUpE7vpmoR3ztO&index=1
下一篇:搭建一个CRM系统5 - 11
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。