# 后端from django.shortcuts import render, HttpResponsefrom django.http import JsonResponsefrom app01 import modelsimport jsonfrom django.db.models import Qdef imgs(request): return render(request, 'img.html')def get_imgs(request): nid = request.GET.get('nid') img_list = models.Img.objects.filter(Q(id__gt=nid)&Q(id__lt=(nid+7))).values('id', 'src', 'title') # 一次从数据库取7张图片 img_list = list(img_list) ret = { 'status': True, 'data': img_list } return JsonResponse(ret)
# HTMLTitle 姑娘们