parent
3d8be360ef
commit
16ff43e0ec
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="PublishConfigData" remoteFilesAllowedToDisappearOnAutoupload="false">
|
||||||
|
<serverData>
|
||||||
|
<paths name="root@222.187.226.110:35261">
|
||||||
|
<serverdata>
|
||||||
|
<mappings>
|
||||||
|
<mapping local="$PROJECT_DIR$" web="/" />
|
||||||
|
</mappings>
|
||||||
|
</serverdata>
|
||||||
|
</paths>
|
||||||
|
</serverData>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
@ -1,6 +1,6 @@
|
|||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from Student.views import *
|
from .views import *
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", studnets)
|
path("", studnets)
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Time : 2023/9/7 10:54
|
||||||
|
# Author : lirunsheng
|
||||||
|
# User : l'r's
|
||||||
|
# Software: PyCharm
|
||||||
|
# File : urls.py
|
||||||
|
|
||||||
|
from django.urls import path
|
||||||
|
|
||||||
|
from .views import *
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path("", teacher)
|
||||||
|
]
|
@ -1,3 +1,54 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
|
from django.http import JsonResponse
|
||||||
|
from .models import Teacher
|
||||||
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
from django.http import QueryDict
|
||||||
|
@csrf_exempt
|
||||||
|
def teacher(request):
|
||||||
|
if request.method == "POST":
|
||||||
|
teacher_information = Teacher()
|
||||||
|
teacher_information.t_name = request.POST.get('t_name')
|
||||||
|
teacher_information.t_sex = request.POST.get('t_sex')
|
||||||
|
teacher_information.t_title = request.POST.get('t_title')
|
||||||
|
teacher_information.t_education = request.POST.get('t_education')
|
||||||
|
teacher_information.t_dept = request.POST.get('t_dept')
|
||||||
|
teacher_information.save()
|
||||||
|
print(teacher_information.t_name)
|
||||||
|
return JsonResponse({'code': 200, 'msg': 'success',"data": teacher_information.to_dict()}, safe=False)
|
||||||
|
|
||||||
|
elif request.method == "GET":
|
||||||
|
t_name = request.GET.get('t_name')
|
||||||
|
t_sex = request.GET.get('t_sex')
|
||||||
|
t_title = request.GET.get('t_title')
|
||||||
|
t_education = request.GET.get('t_education')
|
||||||
|
t_dept = request.GET.get('t_dept')
|
||||||
|
data = []
|
||||||
|
if t_name:
|
||||||
|
filtered = Teacher.objects.filter(t_name=t_name)
|
||||||
|
for teacher_x in filtered:
|
||||||
|
data.append(teacher_x.to_dict())
|
||||||
|
elif t_sex:
|
||||||
|
filtered = Teacher.objects.filter(t_sex=t_sex)
|
||||||
|
for teacher_x in filtered:
|
||||||
|
data.append(teacher_x.to_dict())
|
||||||
|
elif t_title:
|
||||||
|
filtered = Teacher.objects.filter(t_title=t_title)
|
||||||
|
for teacher_x in filtered:
|
||||||
|
data.append(teacher_x.to_dict())
|
||||||
|
elif t_education:
|
||||||
|
filtered = Teacher.objects.filter(t_education=t_education)
|
||||||
|
for teacher_x in filtered:
|
||||||
|
data.append(teacher_x.to_dict())
|
||||||
|
elif t_dept:
|
||||||
|
filtered = Teacher.objects.filter(t_dept=t_dept)
|
||||||
|
for teacher_x in filtered:
|
||||||
|
data.append(teacher_x.to_dict())
|
||||||
|
else:
|
||||||
|
all_objects = Teacher.objects.all()
|
||||||
|
for teacher_x in all_objects:
|
||||||
|
data.append(teacher_x.to_dict())
|
||||||
|
return JsonResponse({'code': 200, 'msg': 'success', 'data': data}, safe=False)
|
Loading…
Reference in new issue