django中瀑布流初探
img.html
Title .w{ width: 1000px; margin: 0 auto; } .item{ width: 25%; float: left; } .item img{ width: 100%; } 姑娘们 11 22 33 44
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
以上就是本次介绍的全部实例内容,大家可以在本次测试下,感谢大家对考高分网的支持。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)