django中瀑布流写法实例代码
(编辑:jimmy 日期: 2024/11/20 浏览:3 次 )
django中瀑布流初探
img.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> .w{ width: 1000px; margin: 0 auto; } .item{ width: 25%; float: left; } .item img{ width: 100%; } </style> </head> <body> <div>姑娘们</div> <div class="w" id="container"> <div class="item">11 </div> <div class="item">22 </div> <div class="item">33 </div> <div class="item">44 </div> </div> <script src="/UploadFiles/2021-04-08/jquery-1.12.4.js">views
def imgs(request): # img_list = models.Img.objects.all() return render(request,'img.html') def get_imgs(request): nid = request.GET.get('nid') img_list = models.Img.objects.filter(id__gt=nid).values('id','src','title') img_list = list(img_list) ret = { 'status': True, 'data': img_list } # return HttpResponse(json.dumps(ret)) return JsonResponse(ret) # return JsonResponse([11,22,33],safe=False)models
class Img(models.Model): src = models.FileField(max_length=32,verbose_name='图片路径',upload_to='static/upload') title = models.CharField(max_length=16,verbose_name='标题') summary = models.CharField(max_length=128,verbose_name='简介') class Meta: verbose_name_plural = '图片' def __str__(self): return self.title以上就是本次介绍的全部实例内容,大家可以在本次测试下,感谢大家对的支持。
下一篇:利用Python产生加密表和解密表的实现方法