python - Method Decorator in class based view is not working -
i using class based view , applied permission classes on post method using method decorator. till yesterday working of sudden stopped. unable find issue.
class offercreatelistview(listcreateapiview): serializer_class = offerserializer queryset = offers.objects.filter(user__isnull=true) @method_decorator(permission_classes((isauthenticated,))) @method_decorator(authentication_classes((basicauthentication, sessionauthentication, tokenauthentication,))) def post(self, request, *args, **kwargs): return super(offercreatelistview, self).post(request, *args, **kwargs)
where doing wrong. there setting work??
the permission_classes
, authentication_classes
decorators designed function based views. haven't followed rest framework code way through, i'm surprised worked until yesterday -- don't decorators intended used class based views.
instead, set attributes on class. since want permission class applied post requests, sounds want isauthenticatedorreadonly
.
class offercreatelistview(listcreateapiview): permission_classes = (isauthenticatedorreadonly,) authentication_classes = (basicauthentication, sessionauthentication, tokenauthentication,) serializer_class = offerserializer queryset = offers.objects.filter(user__isnull=true)
Comments
Post a Comment