rest_framework_json_api.views module

class rest_framework_json_api.views.PreloadIncludesMixin

Bases: object

This mixin provides a helper attributes to select or 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__': [],
        'category.section': ['category']
    }
    select_for_includes = {
        '__all__': [],
        'author': ['author', 'author__authorbio'],
    }
get_queryset(*args, **kwargs)
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

Mixing handling related links.

This mixin handles all related entities, whose Serializers are declared in “related_serializers”.

class rest_framework_json_api.views.ModelViewSet(**kwargs)

Bases: AutoPrefetchMixin, PreloadIncludesMixin, RelatedMixin, ModelViewSet

http_method_names = ['get', 'post', 'patch', 'delete', 'head', 'options']
class rest_framework_json_api.views.ReadOnlyModelViewSet(**kwargs)

Bases: AutoPrefetchMixin, PreloadIncludesMixin, RelatedMixin, ReadOnlyModelViewSet

http_method_names = ['get', 'post', 'patch', 'delete', 'head', 'options']
class rest_framework_json_api.views.RelationshipView(**kwargs)

Bases: GenericAPIView

serializer_class

alias of ResourceIdentifierObjectSerializer

field_name_mapping = {}
http_method_names = ['get', 'post', 'patch', 'delete', 'head', 'options']
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(request, *args, **kwargs)
remove_relationships(instance_manager, field)
patch(request, *args, **kwargs)
post(request, *args, **kwargs)
delete(request, *args, **kwargs)
get_resource_name()
set_resource_name(value)
property resource_name