Viewsets#
- class djangoapp_sample.viewsets.mixins.ConditionalResumedSerializerMixin[source]#
Overrides get_serializer_class to use a resumed Serializer in list.
Set
resumed_serializer_class
attribute on your viewset to enable this behavior else the default serializer fromserializer_class
is always used.This won’t work with classes which does not set attribute
action
likeAPIView
.The goal of this behavior is to have lighter payload on lists which does not need to return everything from an object.
- class djangoapp_sample.viewsets.blog.BlogViewSet(**kwargs)[source]#
Viewset for all HTTP methods on Blog model.
- serializer_class#
alias of
BlogSerializer
- get_queryset()[source]#
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)
- class djangoapp_sample.viewsets.article.ArticleViewSet(**kwargs)[source]#
Viewset for all HTTP methods on Article model.
- serializer_class#
alias of
ArticleSerializer
- resumed_serializer_class#
alias of
ArticleResumeSerializer
- get_queryset()[source]#
Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.
This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.
You may want to override this if you need to provide different querysets depending on the incoming request.
(Eg. return a list of items that is specific to the user)