DRF框架中链表数据通过ModelSerializer深度查询方法汇总 一.准备测试和理解准备 创建类 class Test1(models.Model): id = models.IntegerField(primary_key=True) test_2_id= models.ForeignKey(to='Test2',on_delete='id') #这里有的创建失败了哈哈忘了会自动补全id class Test2(models.Model): id = models.IntegerFiel…
import json from django.db import DatabaseError from django.http import HttpResponse from django.http import JsonResponse from django.shortcuts import render # Create your views here. from django.views import View # http://127.0.0.1:8000/books/ from…