教師が生徒をチェックしてください:
まず、学生のテーブル(逆引き)teacher__idをチェックし、教師のIDを取得し、一致した教師は、ID、ショーの最後のシーケンスを渡します
小切手での学生の先生:
最初の学生IDを取得し、その後、教師テーブル(外部キー)STU、学生証上マッチングパス、ショーの最終配列を確認
class ShowTea(APIView):
def get(self,request):
tea = Teacher.objects.all()
ser = TeaSer(tea, many=True)
return Response({
'code': 200,
'data': ser.data
})
class Shows(APIView):
def post(self,request):
id = request.data.get('id')
stu = Student.objects.filter(teacher__id=id)
ser = StudentSer(stu,many=True)
return Response(ser.data)
class Showtt(APIView):
def post(self,request):
id = request.data.get('id')
tea = Teacher.objects.filter(stu=id)
tea = TeacherSer(stu,many=True)
return Response(ser.data)
<template>
<div>
<table border="1">
<tr>
<th>老师</th>
</tr>
<tr v-for="item in datalist">
<td><button @click="shos(item.id)">{{ item.name }}</button></td>
</tr>
<div v-for="i in ss">
<button @click="ttt(i.id)">{{ i.name }}</button>
</div>
<li v-for="i in tt">{{ i.name }}</li>
</table>
</div>
</template>
<script>
import axios from 'axios'
export default {
data(){
return{
datalist:[],
ss:[],
tt:[]
}
},
mounted() {
axios({
url:'http://localhost:8000/showtea/',
method:'get'
}).then(res=>{
console.log(res);
this.datalist = res.data.data;
})
},
methods:{
shos(id){
axios({
url:'http://localhost:8000/shows/',
method:'post',
data:{'id':id}
}).then(res=>{
console.log(res);
this.ss = res.data
})
},
ttt(id){
axios({
url:'http://localhost:8000/showtt/',
method:'post',
data:{'id':id}
}).then(res=>{
console.log(res);
this.tt = res.data
})
}
}
}
</script>
<style scoped>
</style>