Reputation: 857
In a Django Rest Framework ViewSet I have an overrided list()
class TicketViewSet(mixins.ListModelMixin,
viewsets.GenericViewSet):
def_list():
make_my_checks()
things_copied_from_parent()
Since the list() has many lines of code and I must make checks in every ViewSet, how can I make this checks and return the overrided method? A thing like:
def_list():
make_my_checks()
super(list())
Upvotes: 5
Views: 2839
Reputation: 88689
You are almost there!!!
class TicketViewSet(mixins.ListModelMixin, viewsets.GenericViewSet):
def list(self, request, *args, **kwargs):
make_my_checks() # your custom checks
return super().list(request, *args, **kwargs) # you should return them
Upvotes: 10