学生管理系统———Django

本文档详细介绍了如何使用Django框架创建一个学生管理系统。涵盖了从项目创建、静态文件配置、数据库设置、路由配置到模板页面的制作全过程,包括添加、显示学生信息的功能。
摘要由CSDN通过智能技术生成

目录

一、开始任务

添加与显示学生信息

二、实现项目

(一)、创建Django项目---students

(二)、准备静态文件夹static

 在static目录下创建css文件夹,并在其中创建main.css文件

(三)、添加layui框架

在static里添加layui框架

(四)、创建脚本文件 

在static目录下新建js文件夹,在其中创建mai.js文件 

(五)、配置数据库 

        配置settings.py文件

       在配置文件settings.py里配置数据库信息       

       在配置文件settings.py里配置静态文件目录

       新建数据库students

       设置数据库连接模块 

       迁移数据库  

      查看生成的数据表 

 三、配置路由

(一)、配置主路由 - students里的urls.py文件

(二)、创建index应用--index

(三)、创建学生模型 - Student

               在index的models.py里创建Student模型类 

              在index的views.py里创建三个视图函数

             在主路由文件里导入上述三个视图函数

(四)、数据迁移,生成学生表

(五)、修改视图函数

   定义初始化函数 --- init()

   修改首页视图函数 --- indexView

  修改添加学生视图 --- addStudentView

  修改显示学生视图 --- showStudentView

 四、创建模板页面

(一)、创建框架模板页面 --- frame.html

(二)、创建首页模板 --- index.html

(三)、创建添加学生页面 --- addstudent.html

(四)、创建显示学生信息模板 - showstudent.html

 五、最终效果


一、开始任务

  • 添加与显示学生信息

二、实现项目

(一)、创建Django项目---students

(二)、准备静态文件夹static

  •  在static目录下创建css文件夹,并在其中创建main.css文件

main.css源码如下:

* {
    margin: 0px;
    padding: 0px;
    border: none;
}

html, body {
    height: 100%;
}

.w1200 {
    width: 1200px;
}

.layui-header, .layui-footer {
    text-align: center;
    margin: auto;
}

.layui-header {
    padding: 40px 0px;
    line-height: 1.5em;
    position: fixed;
    background-image: linear-gradient(to bottom, olive, deepskyblue, cornflowerblue, mediumorchid);
}

.layui-footer {
    padding: 30px 0px;
    position: relative;
    background-image: linear-gradient(to bottom, mediumorchid, cornflowerblue, deepskyblue, olive);
}

.layui-footer a {
    margin: 0px 20px;
}

.layui-footer a:hover {
    color: red;
}

.layui-footer p {
    margin: 15px 0px;
}

.bold {
    font-weight: bold;
}

.middle {
    display: flex;
    flex-direction: row;
    margin: 5px 0px;
    min-height: 500px;
}

.left-menu {
    flex: 1;
    background: azure;
    padding: 20px;
}

.right-content {
    flex: 5;
    margin-left: 5px;
    background: azure;
    padding: 20px;
}

.test-info h4 {
    font-size: 20px;
    font-weight: bolder;
}

.test-info p {
    font-size: 15px;
    line-height: 2em;
    text-indent: 2em;
}

form {
    margin: auto;
}

form table {
    width: 400px;
    margin: auto;
    border: 1px solid black;
    padding: 50px 20px !important;
}

form table th {
    width: 100px;
    text-align: right;
}

form table td {
    width: 250px;
    padding: 0px 10px;
}

tr {
    line-height: 4em;
}

table tr:last-child {
    text-align: center;
}

table caption {
    font-weight: bolder;
    padding: 10px 0px;
    font-size: 1.5em;
}

.stuinfo {
    width: 90% !important;
    margin: auto;
    text-align: center;
}

.stuinfo table {
    margin: auto !important;
    width: 90% !important;
}

.stuinfo table td {
    width: 25%;
}

.stuinfo table tr {
    border-bottom: 1px solid black;
}

.stuinfo thead {
    background: black;
}

.stuinfo thead th {
    color: white;
    border-right: 1px solid white;
}

.stuinfo table tr:nth-child(even) {
    background: #2D93CA;
}

.stuinfo table tr:hover td {
    background: #00FFFF;
}

(三)、添加layui框架

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值