学生管理系统(用中间件)-------基于FORM组件

学生管理系统(用中间件)-------基于FORM组件,第1张

概述x学生管理系统(用中间件)-------基于FORM组件 目的:实现学生,老师,课程的增删改查 models.py   from django.db import models# Create your models here.class UserInfo(models.Model): """ 用户表:既有班主任也有老师 """ username = mode x学生管理系统(用中间件)-------基于FORM组件

目的:实现学生,老师,课程的增删改查

models.py

 

from django.db import models# Create your models here.class UserInfo(models.Model):    """    用户表:既有班主任也有老师    """    username = models.CharFIEld(max_length=32)    password = models.CharFIEld(max_length=64)    email = models.CharFIEld(max_length=32)    ut = models.ForeignKey(to="UserType")  #用户和用户类型一对多的关系    teacher_classes = models.ManyToManyFIEld(to="Classes")  #老师和班级的多对多关系class UserType(models.Model):    """    用户类型表    """    Title = models.CharFIEld(max_length=32)class Classes(models.Model):    """    班级表    """    name = models.CharFIEld(max_length=32)    classteacher = models.ForeignKey(to="UserInfo")  #班级和班主任是一对多的关系class Student(models.Model):    """    学生表    """    name = models.CharFIEld(max_length=32)    age = models.IntegerFIEld(max_length=32)    cls = models.ForeignKey(to="Classes")  #学生和班级的一对多关系

 

 

 

1、urls.py

@H_419_86@
 1 from django.conf.urls import url 2 from django.contrib import admin 3 from app01 import vIEws 4 urlpatterns = [ 5     url(r^admin/,admin.site.urls), 6     url(r^login/,vIEws.login), 7     #老师管理 8     url(r^teacherindex/,vIEws.teacherindex), 9     url(r^addteacher/,vIEws.addteacher),10     url(r^editteacher/(\d+),vIEws.editteacher),11     url(r^delteacher/(\d+),vIEws.delteacher),12     #学生管理13     url(r^studentindex/,vIEws.studentindex),14     url(r^addstudent/,vIEws.addstudent),15     url(r^delstudent/(\d+),vIEws.delstudent),16     url(r^editstudent/(\d+),vIEws.editstudent),17 18     #班级管理19     url(r^classindex/,vIEws.classindex),20     url(r^addclass/,vIEws.addclass),21     url(r^delclass/(\d+),vIEws.delclass),22     url(r^editclass/(\d+),vIEws.editclass),23 24     #测试中间件25     url(r^test,vIEws.testMD),26 ]
urls.py

2、vIEws.py 

  1 from django.shortcuts import render,redirect,httpResponse  2 from app01 import models  3 # Create your vIEws here.  4 from django.forms import Form  5 from django.forms import fIElds  6 from django.forms import Widgets  7 from django.conf import settings  8 from django.core.valIDators import ValIDationError  9 from django.core.valIDators import RegexValIDator 10 # 1、创建规则 11 class TeacherForm(Form):  #必须继承Form 12     # 创建字段,本质上是正则表达式 13     username = fIElds.CharFIEld( 14         required=True,#必填字段 15         error_messages={"required":"用户名不能为空!!"},#显示中文错误提示 16         Widget=Widgets.Textinput(attrs={"placeholder":"用户名","class":"form-control"}),#自动生成input框 17         label="姓名", 18         label_suffix=":" 19        ) 20     password = fIElds.CharFIEld(required=True,error_messages={required: 密码不能为空}, 21                                 Widget=Widgets.Passwordinput(attrs={placeholder: 密码,class: form-control}), 22                                 label="密码", 23                                 label_suffix=":" 24       )  # 不能为空 25  26     email = fIElds.EmailFIEld( 27         required=True, 28         error_messages={"required":"邮箱不能为空!!","invalID":"无效的邮箱"}, 29         Widget=Widgets.Emailinput(attrs={"placeholder": "邮箱","class": "form-control"}),# 自动生成input框 30         label = "邮箱", 31         label_suffix = ":" 32     ) #不能为空且邮箱格式要一致 33     teacher_classes = fIElds.MultipleChoiceFIEld( 34         label="任教班级", 35         label_suffix=":", 36         choices=[]  #注意一定要用values_List 37  38     ) 39  40     def __init__(self,*args,**kwargs): 41         super().__init__(*args,**kwargs) 42         self.fIElds["teacher_classes"].choices = models.Classes.objects.values_List("ID","name") 43  44     def clean_name(self): 45         name = self.cleaned_data["name"] 46         valID = models.Student.objects.filter(name=name).first() 47         if valID: 48             raise ValIDationError("用户名已存在") 49         return name 50  51 class LoginForm(Form): 52     username = fIElds.CharFIEld( 53         required=True,#必填字段 54         min_length=3, 55         max_length=16, 56         error_messages={ 57             "required":"用户名不能为空", 58             "min_length":"长度不能小于3", 59             "max_length":"长度不能大于16" 60         }, 61         Widget=Widgets.Textinput({"placeholder":"username","class":"form-control"}) 62     ) 63     password = fIElds.CharFIEld( 64         required=True, 65         min_length=3, 66         max_length=16, 67         error_messages={ 68             "required": "密码不能为空", 69             "min_length": "密码长度不能小于3", 70             "max_length": "密码长度不能大于16", 71             # "invalID":"密码格式错误" 72             # error_messages的优先级高,如果写上"invalID":"密码格式错误"这个就会优先显示这个错误 73         }, 74         Widget=Widgets.Passwordinput({"placeholder":"password","class":"form-control"}), 75         valIDators=[RegexValIDator("\d+","密码只能是数字")]  #可以进行正则匹配提示错误 76     ) 77  78     def clean_username(self): 79         user = self.cleaned_data["username"] 80         is_exits = models.UserInfo.objects.filter(username=user).count() 81         if not is_exits: 82             raise ValIDationError("用户名和密码错误") 83         return user   #必须有return 84  85 class StudentForm(Form):  #必须继承Form 86     # 创建字段,本质上是正则表达式 87  88     name = fIElds.CharFIEld( 89         required=True,#必填字段 90         error_messages={"required":"姓名不能为空!!"},#显示中文错误提示 91         Widget=Widgets.Textinput(attrs={"placeholder":"姓名",#自动生成input框 92        ) 93     age = fIElds.CharFIEld(required=True,error_messages={required: 年龄不能为空}, 94                            Widget=Widgets.Textinput(attrs={placeholder: 年龄, 95       )  # 不能为空 96     class_List = models.Classes.objects.all().values_List(ID,"name") 97     cls_ID=fIElds.ChoiceFIEld(choices=class_List) 98     # 这个方法判断用户名存在不 99     def clean_name(self):100         name = self.cleaned_data["name"]   #只能拿自己当前的字段值101         valID = models.Student.objects.filter(name=name).first()102         if valID:103             raise ValIDationError("用户名已存在")  #主动报错104         return name   #必须有返回值105 106 class ClassesForm(Form):107     name = fIElds.CharFIEld(108         required=True,# 必填字段109         error_messages={"required": "姓名不能为空!!"},# 显示中文错误提示110         Widget=Widgets.Textinput(attrs={"placeholder": "姓名",# 自动生成input框111     )112     # 如果直接定义成classteacher_ID,,_ID 的形式,这样你添加数据的时候不会时时更新,所以在下面定义一个重写的方法113     # classteacher_ID = fIElds.ChoiceFIEld(choices= models.UserInfo.objects.filter(ut_ID = settings.RolE_CLAsstEACHER).values_List(‘ID‘,"username"))114 115     classteacher_ID = fIElds.ChoiceFIEld(choices=[])116     def __init__(self,**kwargs):   #重写init方法,时时更新117         super().__init__(*args,**kwargs)118         self.fIElds["classteacher_ID"].choices = models.UserInfo.objects.filter(ut_ID = settings.RolE_CLAsstEACHER).values_List(ID,"username")119 120 def login(request):121     if request.method == "GET":122         form = LoginForm()123         return render(request,"login.HTML",{"form": form})124     else:125         form = LoginForm(data=request.POST)126         if form.is_valID():127             print(form.cleaned_data)128             user = models.UserInfo.objects.filter(**form.cleaned_data).first()129             if user:  #这次是和数据库里的数据进行比较130                 #验证成功131                 print(user.username)132                 request.session[settings.GDP] = {"ID":user.ID,"username":user.username}  #设置session133                 return redirect("/teacherindex/")134             else:135                 #验证失败,就给增加一个错136                 form.add_error("password","用户名或密码不正确")137                 return render(request,{"form": form})138         else:139             return render(request,{"form": form})140 141 # 用装饰器的方法实现验证,如果是正确的用户就可以进去主页并且 *** 作,如果不是就进不去主页,还让在登录页面上142 # 这个方法可以是可以,但是你的函数要是有成百上千个,那每个都加装饰器是不是就有点费事了。143 # 那还有一种更牛逼的方法,那就是中间件。用中间件就可以实现和装饰器一样的功能了144 def auth(func):145     def inner(request,**kwargs):146         user_info = request.session.get("username")147         if not user_info:148             return redirect(/login/)149         return func(request,**kwargs)150     return inner151 #老师主页面152 153 def teacherindex(request):154     teacher_obj = models.UserInfo.objects.filter(ut_ID=1)155     username = request.session.get("username")156     return render(request,"teacherindex.HTML",{"teacher_obj":teacher_obj,"username":username})157 # 2、使用规则:将数据和规则进行匹配158 159 def addteacher(request):160     if request.method=="GET":161         form = TeacherForm()  #只是让显示一个input框162         return render(request,"addteacher.HTML",{"form":form})163     else:164         form = TeacherForm(data=request.POST)165         # print(form)  #<querySet [<UserInfo: UserInfo object>,<UserInfo: UserInfo object>,<UserInfo: UserInfo object>]>166         if form.is_valID():# 开始验证167             cls_List = form.cleaned_data.pop("teacher_classes")168             print("============ID",cls_List)169             form.cleaned_data[ut_ID] = 1170             #创建新老师的对象171             teacher_obj = models.UserInfo.objects.create(**form.cleaned_data)172             #创建新老师和班级的关系173             teacher_obj.teacher_classes.add(*cls_List)  #以前添加的是对象,现在也可以吧ID添加进去174             return redirect("/teacherindex/")175         else:176             # print("=====?",form.errors,type(form.errors))#返回失败的结果177             # print(form.errors["username"][0])   #拿到返回失败的结果,渲染到页面178             return render(request,{"form":form})179 180 def editteacher(request,nID):181     obj = models.UserInfo.objects.filter(ID=nID,ut_ID=1).first()182     # print(obj.username)183     if not obj:184         return redirect("/teacherindex/")185     if request.method=="GET":186         print([obj.ID for obj in obj.teacher_classes.all()])  #[2]  拿到select框的ID是为了要做默认显示的187         form = TeacherForm(initial={"username":obj.username,"password":obj.password,"email":obj.email,"teacher_classes":[obj.ID for obj in obj.teacher_classes.all()]}) #就让显示一个input框,并且带有原来哪一行的内容188         return render(request,"editteacher.HTML",{"form":form})189     else:190         form = TeacherForm(data=request.POST)191         if form.is_valID():#开始校验,注意这要加括号192             cls_List = form.cleaned_data.pop("teacher_classes")193             print(cls_List)194             models.UserInfo.objects.filter(ID=nID).update(**form.cleaned_data)195             obj.teacher_classes.set(cls_List)   #更新第三张表196             return redirect("/teacherindex/")197         else:198             return render(request,{"form":form})199 200 def delteacher(request,nID):201     models.UserInfo.objects.filter(ID=nID).delete()202     return redirect("/teacherindex/")203 204 205 206 def studentindex(request):207     username = request.session.get("username")208     student_obj = models.Student.objects.all()209     return render(request,"studentindex.HTML",{"student_obj":student_obj,"username":username})210 211 def addstudent(request):212     if request.method=="GET":213         form = StudentForm()214         return render(request,"addstudent.HTML",{"form":form})215     else:216         form = StudentForm(data=request.POST)217         if form.is_valID():218             print(form.cleaned_data)219             models.Student.objects.create(**form.cleaned_data)220             return redirect("/studentindex/")221         else:222             return render(request,{"form":form})223 224 def delstudent(request,nID):225     models.Student.objects.filter(ID=nID).delete()226     return redirect("/studentindex/")227 228 def editstudent(request,nID):229     if request.method=="GET":230         student_obj = models.Student.objects.filter(ID=nID).first()231         print(student_obj.cls_ID)232         if not student_obj:233             return redirect("/studentindex/")234         form = StudentForm(initial={"name":student_obj.name,"age":student_obj.age,"cls_ID":student_obj.cls_ID})  #这个name是设置的字段名235         # form = StudentForm(initial=student_obj.values("name","age").first())  #显示input并且让带有你点击哪一行的数据236         return render(request,"editstudent.HTML",{"form":form})237     else:238         form = StudentForm(data=request.POST)239         if form.is_valID():240             models.Student.objects.filter(ID=nID).update(**form.cleaned_data)241             return redirect("/studentindex/")242         else:243             return render(request,{"form":form})244 245 246 247 def classindex(request):248     class_obj = models.Classes.objects.all()249     username = request.session.get("username")250     return render(request,"classindex.HTML",{"class_obj":class_obj,"username":username})251 252 def delclass(request,nID):253     models.Classes.objects.filter(ID=nID).delete()254     return redirect("/classindex/")255 256 def addclass(request):257     if request.method=="GET":258         form = ClassesForm()259         return render(request,"addclass.HTML",{"form":form})260     else:261         form = ClassesForm(data=request.POST)262         if form.is_valID():263             print(form.cleaned_data)264             models.Classes.objects.create(**form.cleaned_data)265             return redirect("/classindex/")266         else:267             return render(request,{"form":form})268 269 def editclass(request,nID):270     if request.method == "GET":271         class_obj = models.Classes.objects.filter(ID=nID).first()272         if not class_obj:273             return redirect("/classindex/")274         form = ClassesForm(initial={"name": class_obj.name,"classteacher_ID":class_obj.classteacher_ID})  # 这个name是设置的字段名,后面的那个做默认选中275         # form = StudentForm(initial=student_obj.values("name","age").first())  #显示input并且让带有你点击哪一行的数据276         return render(request,"editclass.HTML",{"form": form})277     else:278         form = ClassesForm(data=request.POST)279         if form.is_valID():280             models.Classes.objects.filter(ID=nID).update(**form.cleaned_data)281             return redirect("/classindex/")282         else:283             return render(request,{"form": form})284 285 286 def testMD(request):287     print("vIEw.test")288     return httpResponse("...")
VIEws.py

3、template

 1 <!DOCTYPE HTML> 2 <HTML lang="en"> 3 <head> 4     <Meta charset="UTF-8"> 5     <Meta http-equiv="X-UA-Compatible" content="IE=edge"> 6     <Meta name="vIEwport" content="wIDth=device-wIDth"> 7     <Title>Title</Title> 8 </head> 9 <body>10 <form method="post" novalIDate>11     {% csrf_token %}12     <p>用户名:{{ form.username }}{{ form.username.errors.0 }}</p>13     <p>密码:{{ form.password }}{{ form.password.errors.0 }}</p>14     <p>{{ s }}</p>15     <p><input type="submit"></p>16 </form>17 </body>18 </HTML>
login.HTML

 1 <!DOCTYPE HTML> 2 <HTML lang="en"> 3 <head> 4     <Meta charset="UTF-8"> 5     <Meta http-equiv="X-UA-Compatible" content="IE=edge"> 6     <Meta name="vIEwport" content="wIDth=device-wIDth"> 7     <Title>Title</Title> 8     <style> 9         .left{10             wIDth: 30%;11             height: 400px;12             position: relative;13         }14         .right{15             wIDth: 60%;16             height: 400px;17             position: absolute;18             left: 300px;19             top: 90px;20         }21         .c1{22             margin-top: 100px;23         }24     </style>25 </head>26 <body>27 <hr>28 <div class="c1">29     <div class="left">30         <ul>31             <li><a href="/teacherindex/">老师管理</a></li>32             <li><a href="/studentindex/">学生管理</a></li>33             <li><a href="/classindex/">班级管理</a></li>34         </ul>35     </div>36     <div class="right">37         {% block right %}38 39         {% endblock %}40     </div>41 </div>42 </body>43 </HTML>
base.HTML @H_929_3014@

@H_981_3016@

@H_704_3019@

 1 {% extends "base.HTML" %} 2 {% block right %} 3     <h2>欢迎{{ username }}登录</h2> 4     <h3>学生信息管理</h3> 5     <hr> 6     <a href="/addstudent/"><button>添加学生</button></a> 7     <table border="1"> 8        <thead> 9             <tr>10                 <th>编号</th>11                 <th>姓名</th>12                 <th>年龄</th>13                 <th>班级</th>14                 <th> *** 作</th>15             </tr>16        </thead>17         <tbody>18         {% for s_obj in student_obj %}19             <tr>20                     <td>{{ forloop.counter }}</td>21                     <td>{{ s_obj.name }}</td>22                     <td>{{ s_obj.age }}</td>23                     <td>{{ s_obj.cls.name }}</td>24                     <td>25                         <a href="/editstudent/{{ s_obj.ID }}"><button>编辑</button></a>26                         <a href="/delstudent/{{ s_obj.ID }}"><button>删除</button></a>27                     </td>28             </tr>29         {% endfor %}30         </tbody>31    </table>32 {% endblock %}
studentindex.HTML

 1 {% extends "base.HTML" %} 2 {% block right %} 3     <h2>欢迎{{ username }}登录</h2> 4     <h3>老师信息管理</h3> 5     <hr> 6     <a href="/addteacher/"><button>添加老师</button></a> 7     <table border="1"> 8        <thead> 9             <tr>10                 <th>编号</th>11                 <th>姓名</th>12                 <th>邮箱</th>13                 <th>任教班级</th>14                 <th> *** 作</th>15             </tr>16        </thead>17         <tbody>18         {% for t_obj in teacher_obj %}19             <tr>20                     <td>{{ forloop.counter }}</td>21                     <td>{{ t_obj.username }}</td>22                     <td>{{ t_obj.email }}</td>23 {#                    <td>{{ t_obj.teacher_classes }}</td>#}24 {#                    多对多查关联字段#}25                     <td>26                         {% for foo in t_obj.teacher_classes.all %}27                             {{ foo.name }}28                         {% endfor %}29                     </td>30                     <td>31                         <a href="/editteacher/{{ t_obj.ID }}"><button>编辑</button></a>32                         <a href="/delteacher/{{ t_obj.ID }}"><button>删除</button></a>33                     </td>34             </tr>35         {% endfor %}36         </tbody>37    </table>38 {% endblock %}
teacherindex.HTML

 1 {% extends "base.HTML" %} 2 {% block right %} 3     <h2>欢迎{{ username }}登录</h2> 4     <h3>班级信息管理</h3> 5     <hr> 6     <a href="/addclass/"><button>添加班级</button></a> 7     <table border="1"> 8        <thead> 9             <tr>10                 <th>编号</th>11                 <th>姓名</th>12                 <th>班主任</th>13                 <th> *** 作</th>14             </tr>15        </thead>16         <tbody>17         {% for c_obj in class_obj %}18             <tr>19                     <td>{{ forloop.counter }}</td>20                     <td>{{ c_obj.name }}</td>21                     <td>{{ c_obj.classteacher.username }}</td>22 {#                    <td>{{ t_obj.ut.Title }}</td>#}23                     <td>24                         <a href="/editclass/{{ c_obj.ID }}"><button>编辑</button></a>25                         <a href="/delclass/{{ c_obj.ID }}"><button>删除</button></a>26                     </td>27             </tr>28         {% endfor %}29         </tbody>30    </table>31 {% endblock %}
classindex,HTML

 1 {% extends "base.HTML" %} 2 {% block right %} 3 <form action="" method="post" novalIDate> 4     {% csrf_token %} 5     <h1>添加学生信息</h1> 6     <hr> 7     <p>姓名:{{ form.name }}{{ form.name.errors.0 }}</p> 8     <p>年龄:{{ form.age }}{{ form.age.errors.0 }}</p> 9     <p>班级:{{ form.cls_ID }}{{ form.cls_ID.errors.0 }}</p>10     <input type="submit">11 </form>12 {% endblock %}
addstudent.HTML

 1 {% extends "base.HTML" %} 2 {% block right %} 3     <h1>添加老师信息</h1> 4     <hr> 5     <form method="post" novalIDate> 6         {% csrf_token %} 7 {#        <p>姓名:{{ form.username }}{{ form.errors.username.0 }}</p>#} 8 {#        <p>密码:{{ form.password }}{{ form.errors.password.0 }}</p>#} 9 {#        <p>邮箱:{{ form.email }}{{ form.errors.email.0 }}</p>#}10 {#        也可以循环添加#}11         {% for fIEld in form %}12             <p>{{ fIEld.label_tag }}{{ fIEld }}{{ fIEld.errors.0 }}</p>13         {% endfor %}14 15         <p><input type="submit" value="提交"></p>16     </form>17 {% endblock %}
addteacher.HTML

 1 {% extends "base.HTML" %} 2 {% block right %} 3 <form action="" method="post" novalIDate> 4     {% csrf_token %} 5     <h1>添加班级信息</h1> 6     <hr> 7     <p>班级:{{ form.name }}{{ form.age.errors.0 }}</p> 8     <p>班主任:{{ form.classteacher_ID }}{{ form.classteacher_ID.errors.0 }}</p> 9     <input type="submit">10 </form>11 {% endblock %}
addclass.HTML

 1 {% extends "base.HTML" %} 2 {% block right %} 3 <form action="" method="post" novalIDate> 4     {% csrf_token %} 5     <h1>修改学生信息</h1> 6     <hr> 7     <p>姓名:{{ form.name }}{{ form.name.errors.0 }}</p> 8     <p>年龄:{{ form.age }}{{ form.age.errors.0 }}</p> 9     <p>班级:{{ form.cls_ID }}{{ form.cls_ID.errors.0 }}</p>10     <input type="submit">11 </form>12 {% endblock %}
editstudent

 1 {% extends "base.HTML" %} 2 {% block right %} 3     <h1>修改老师信息</h1> 4     <hr> 5     <form method="post" novalIDate> 6         {% csrf_token %} 7 {#            {{ form.as_p}}#} 8     <p>姓名:{{ form.username }}{{ form.errors.username.0 }}</p> 9     <p>密码:{{ form.password }}{{ form.errors.password.0 }}</p>10     <p>邮箱:{{ form.email }}{{ form.errors.email.0 }}</p>11     <p>任教班级:{{ form.teacher_classes }}</p>12 {#    {% for fIEld in form %}#}13 {#        <p>{{ fIEld.label_tag }}{{ fIEld }}{{ fIEld.errors.0 }}</p>#}14 {#    {% endfor %}#}15     <input type="submit" value="提交">16     </form>17 {% endblock %}
editteacher

 1 {% extends "base.HTML" %} 2 {% block right %} 3 <form action="" method="post" novalIDate> 4     {% csrf_token %} 5     <h1>修改班级信息</h1> 6     <hr> 7     <p>班级:{{ form.name }}{{ form.age.errors.0 }}</p> 8     <p>班主任:{{ form.classteacher_ID }}{{ form.classteacher_ID.errors.0 }}</p> 9     <input type="submit">10 </form>11 {% endblock %}
editclass

4、中间件

 1 #!usr/bin/env python 2 # -*- Coding:utf-8 -*- 3 # from django.utils.deprecation import MIDdlewareMixin 4 from django.conf import settings 5 from django.shortcuts import redirect 6 class MIDdlewareMixin(object): 7     def __init__(self,get_response=None): 8         self.get_response = get_response 9         super(MIDdlewareMixin,self).__init__()10 11     def __call__(self,request):12         response = None13         if hasattr(self,process_request):14             response = self.process_request(request)15         if not response:16             response = self.get_response(request)17         if hasattr(self,process_response):18             response = self.process_response(request,response)19         return response20 21 # 至少要有两个类22 class Md1(MIDdlewareMixin):  #必须继承23     def process_request(self,request):24         print("md1===process_request")25         l = ["/login/"]26         if request.path_info in l:  #因为login不做验证,就直接返回none就行了27             return None28         if not request.session.get(settings.GDP):29             return redirect("/login/")30         #31         # 如果无返回值,就继续执行后续中间件和视图函数32         # 如果有返回值,就执行自己的process_response和上面的response33     def process_response(self,request,response):34         print("md1====process_response1")35         return response   #必须有返回值36 37 class Md2(MIDdlewareMixin):38     def process_request(self,request):39         print("md2====process_request2")40     def process_response(self,response):41         print("md2====process_response2")42         return response
mIDdlewear

5、settings

  1 """  2 Django settings for day75以及周末作业老师管理等 project.  3   4 Generated by ‘django-admin startproject‘ using Django 1.11.6.  5   6 For more information on this file,see  7 https://docs.djangoproject.com/en/1.11/topics/settings/  8   9 For the full List of settings and their values,see 10 https://docs.djangoproject.com/en/1.11/ref/settings/ 11 """ 12  13 import os 14  15 # Build paths insIDe the project like this: os.path.join(BASE_DIR,...) 16 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17  18  19 # Quick-start development settings - unsuitable for production 20 # See https://docs.djangoproject.com/en/1.11/howto/deployment/checkList/ 21  22 # Security WARNING: keep the secret key used in production secret! 23 SECRET_KEY = xi^$lfsye5x43af&)lpkx5l%^4%3$%[email protected]=+nrbwa^!b2aj)! 24  25 # Security WARNING: don‘t run with deBUG turned on in production! 26 DEBUG = True 27  28 ALLOWED_HOSTS = [] 29  30  31 # Application deFinition 32  33 INSTALLED_APPS = [ 34     django.contrib.admin, 35     django.contrib.auth, 36     django.contrib.ContentTypes, 37     django.contrib.sessions, 38     django.contrib.messages, 39     django.contrib.staticfiles, 40     app01.apps.App01Config, 41 ] 42  43 MIDDLEWARE = [ 44     django.mIDdleware.security.SecurityMIDdleware, 45     django.contrib.sessions.mIDdleware.SessionMIDdleware, 46     django.mIDdleware.common.CommonMIDdleware, 47     django.mIDdleware.csrf.CsrfVIEwMIDdleware, 48     django.contrib.auth.mIDdleware.AuthenticationMIDdleware, 49     django.contrib.messages.mIDdleware.MessageMIDdleware, 50     django.mIDdleware.clickjacking.XFrameOptionsMIDdleware, 51     #这是自定义的中间件 52     "mIDdle.mIDdle.Md1", 53     "mIDdle.mIDdle.Md2" 54 ] 55  56 ROOT_URLconf = day75以及周末作业老师管理等.urls 57  58 TEMPLATES = [ 59     { 60         BACKEND: django.template.backends.django.DjangoTemplates, 61         Dirs: [os.path.join(BASE_DIR,templates)] 62 , 63         APP_Dirs: True, 64         OPTIONS: { 65             context_processors: [ 66                 django.template.context_processors.deBUG, 67                 django.template.context_processors.request, 68                 django.contrib.auth.context_processors.auth, 69                 django.contrib.messages.context_processors.messages, 70             ], 71         }, 72     }, 73 ] 74  75 Wsgi_APPliCATION = day75以及周末作业老师管理等.wsgi.application 76  77  78 # Database 79 # https://docs.djangoproject.com/en/1.11/ref/settings/#databases 80  81 DATABASES = { 82     default: { 83         ENGINE: django.db.backends.sqlite3, 84         name: os.path.join(BASE_DIR,db.sqlite3), 85     } 86 } 87  88  89 # Password valIDation 90 # https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-valIDators 91  92 AUTH_PASSWORD_VALIDATORS = [ 93     { 94         name: django.contrib.auth.password_valIDation.UserAttributeSimilarityValIDator, 95     }, 96     { 97         name: django.contrib.auth.password_valIDation.MinimumLengthValIDator, 98     }, 99     {100         name: django.contrib.auth.password_valIDation.CommonPasswordValIDator,101     },102     {103         name: django.contrib.auth.password_valIDation.NumericPasswordValIDator,104     },105 ]106 107 108 # Internationalization109 # https://docs.djangoproject.com/en/1.11/topics/i18n/110 111 LANGUAGE_CODE = en-us112 113 TIME_ZONE = UTC114 115 USE_I18N = True116 117 USE_L10N = True118 119 USE_TZ = True120 121 122 # Static files (CSS,JavaScript,Images)123 # https://docs.djangoproject.com/en/1.11/howto/static-files/124 125 STATIC_URL = /static/126 STATICFIELDS=[127     os.path.join("/static/",BASE_DIR),128 ]129 130 # ============自定义配置文件===========131 RolE_TEACHER = 1132 RolE_CLAsstEACHER = 2133 GDP="user_info"
settings 总结

以上是内存溢出为你收集整理的学生管理系统(用中间件)-------基于FORM组件全部内容,希望文章能够帮你解决学生管理系统(用中间件)-------基于FORM组件所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1190797.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存