admin_mixins.py 文件源码

python
阅读 15 收藏 0 点赞 0 评论 0

项目:newshound 作者: mailbackwards 项目源码 文件源码
def trending(self, request, object_id, **kwargs):
        # a custom view that shows trending dogs
        if request.method == 'GET':
            obj = get_object_or_404(self.model, id=object_id)
            # We could filter by dogs specific to this post here, if needed
            trending_dogs = Dog.trending.all()[:3]
            dogs = DogSerializer(trending_dogs, many=True).data
            return JsonResponse({'results': dogs})
        else:
            return JsonResponse({'results': []})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号