rest_framework_json_api.views module¶
-
class
rest_framework_json_api.views.
PrefetchForIncludesHelperMixin
¶ Bases:
object
-
get_queryset
()¶ This viewset provides a helper attribute to prefetch related models based on the include specified in the URL.
__all__ can be used to specify a prefetch which should be done regardless of the include
# When MyViewSet is called with ?include=author it will prefetch author and authorbio class MyViewSet(viewsets.ModelViewSet): queryset = Book.objects.all() prefetch_for_includes = { '__all__': [], 'author': ['author', 'author__authorbio'], 'category.section': ['category'] }
-
-
class
rest_framework_json_api.views.
AutoPrefetchMixin
¶ Bases:
object
-
get_queryset
(*args, **kwargs)¶ This mixin adds automatic prefetching for OneToOne and ManyToMany fields.
-
-
class
rest_framework_json_api.views.
RelatedMixin
¶ Bases:
object
This mixin handles all related entities, whose Serializers are declared in “related_serializers”
-
get_serializer_class
()¶
-
-
class
rest_framework_json_api.views.
ModelViewSet
(**kwargs)¶ Bases:
rest_framework_json_api.views.AutoPrefetchMixin
,rest_framework_json_api.views.PrefetchForIncludesHelperMixin
,rest_framework_json_api.views.RelatedMixin
,rest_framework.viewsets.ModelViewSet
-
class
rest_framework_json_api.views.
ReadOnlyModelViewSet
(**kwargs)¶ Bases:
rest_framework_json_api.views.AutoPrefetchMixin
,rest_framework_json_api.views.PrefetchForIncludesHelperMixin
,rest_framework_json_api.views.RelatedMixin
,rest_framework.viewsets.ReadOnlyModelViewSet
-
class
rest_framework_json_api.views.
RelationshipView
(**kwargs)¶ Bases:
rest_framework.generics.GenericAPIView
-
serializer_class
¶ alias of
rest_framework_json_api.serializers.ResourceIdentifierObjectSerializer
-
self_link_view_name
= None¶
-
field_name_mapping
= {}¶
-
get_serializer_class
()¶
-
get_url
(name, view_name, kwargs, request)¶ Given a name, view name and kwargs, return the URL that hyperlinks to the object.
May raise a NoReverseMatch if the view_name and lookup_field attributes are not configured to correctly match the URL conf.
-
get_links
()¶
-
get
(request, *args, **kwargs)¶
-
patch
(request, *args, **kwargs)¶
-
post
(request, *args, **kwargs)¶
-
delete
(request, *args, **kwargs)¶
-
get_resource_name
()¶
-
set_resource_name
(value)¶
-
resource_name
¶
-