码迷,mamicode.com
首页 > 其他好文 > 详细

dJANGO RESTFRAMEWORK

时间:2015-07-23 21:59:16      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

1、filter_queryset

class ProductAdd(generics.ListCreateAPIView):

    queryset = Product.objects.all()
    serializer_class = ProductSerializer
    filter_fields = ("status", "sale_supplier")#传入参数过滤
    template_name = "product_add.html"
    permission_classes = (permissions.IsAuthenticated,)

    def get(self, request, *args, **kwargs):
        queryset = self.filter_queryset(self.queryset)#根据参数进行过滤
        page = self.paginate_queryset(queryset)
        ……

Authentication
授权
Auth needs to be pluggable.
认证需要是可插拔的!!
— Jacob Kaplan-Moss, "REST worst practices"

版权声明:本文为博主原创文章,未经博主允许不得转载。

dJANGO RESTFRAMEWORK

标签:

原文地址:http://blog.csdn.net/dale_dede/article/details/47027579

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!