Views#

Contains all the viewsets for the FMA Django API service.

fma_django_api.v1.views.error404(request)#

Creates custom 404 error for django page not found.

Parameters:

request (Any) – Message requesting access to a page in FMA

Raises:

NotFound

class fma_django_api.v1.views.FederatedModelViewSet(**kwargs)#

Bases: ModelViewSet

The viewset for federated models.

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

serializer_class#

alias of FederatedModelSerializer

pagination_class#

alias of LargeResultsSetPagination

queryset#
permission_classes = [<class 'fma_django_api.v1.permissions.IsActive'>]#
ordering_fields = ('created_on',)#
ordering = ('-created_on',)#
filterset_class#

alias of FederatedModelFilter

get_serializer_class()#

Gets the FederatedModel serializer class based on the action requested.

Returns:

serializer class for a Federated Model

get_queryset()#

Gets FederatedModel query_set based on REST requested user parameters.

Returns:

FederatedModel queryset

Return type:

django.db.models.query.QuerySet

register_client(request, *args, **kwargs)#

Allows client to register to a model to perform client specific actions.

Parameters:
  • request (Any) – Message from client to be added to the client list

  • args (Dict, optional) – arguments

  • kwargs (Dict, optional) – keyword arguments

Returns:

Serialized data about the registered client

Return type:

Response

get_latest_aggregate(request, *args, **kwargs)#

Sorts and returns the most recent aggregate to the requester.

Parameters:
  • request (Any) – Message from client asking for latest aggregate

  • args (Dict, optional) – arguments

  • kwargs (Dict, optional) – keyword arguments

Returns:

Serialized data about the latest aggregate

Return type:

Response

get_current_artifact(request, *args, **kwargs)#

Returns the current artifact of the model to the requester.

Parameters:
  • request (Any) – Message from client asking for the current artifact

  • args (Dict, optional) – arguments

  • kwargs (Dict, optional) – Keyword arguments

Returns:

Serialized data about the current artifact

Return type:

Response

get_latest_model(request, *args, **kwargs)#

Returns the latest aggregate of model.

Returns the latest aggregate of the model else if no aggregate exists the current artifact of the model to the requester.

Parameters:
  • request (Any) – Message from client asking for the lastest model

  • args (Dict, optional) – Arguments

  • kwargs (Dict, optional) – Keyword arguments

Returns:

Serialized data about the latest model

Return type:

Response

property allowed_methods#

Wrap Django’s private _allowed_methods interface in a public property.

classmethod as_view(actions=None, **initkwargs)#

Because of the way class based views create a closure around the instantiated view, we need to totally reimplement .as_view, and slightly modify the view function that is created and returned.

authentication_classes = [<class 'rest_framework.authentication.BasicAuthentication'>, <class 'rest_framework.authentication.SessionAuthentication'>, <class 'fma_django.authenticators.ClientAuthentication'>, <class 'rest_framework.authentication.TokenAuthentication'>]#
basename = None#
check_object_permissions(request, obj)#

Check if the request should be permitted for a given object. Raises an appropriate exception if the request is not permitted.

check_permissions(request)#

Check if the request should be permitted. Raises an appropriate exception if the request is not permitted.

check_throttles(request)#

Check if request should be throttled. Raises an appropriate exception if the request is throttled.

content_negotiation_class#

alias of DefaultContentNegotiation

create(request, *args, **kwargs)#
property default_response_headers#
description = None#
destroy(request, *args, **kwargs)#
detail = None#
determine_version(request, *args, **kwargs)#

If versioning is being used, then determine any API version for the incoming request. Returns a two-tuple of (version, versioning_scheme)

dispatch(request, *args, **kwargs)#

.dispatch() is pretty much the same as Django’s regular dispatch, but with extra hooks for startup, finalize, and exception handling.

filter_backends = [<class 'django_filters.rest_framework.backends.DjangoFilterBackend'>, <class 'rest_framework.filters.OrderingFilter'>]#
filter_queryset(queryset)#

Given a queryset, filter it with whichever filter backend is in use.

You are unlikely to want to override this method, although you may need to call it either from a list view, or from a custom get_object method if you want to apply the configured filtering backend to the default queryset.

finalize_response(request, response, *args, **kwargs)#

Returns the final response object.

get_authenticate_header(request)#

If a request is unauthenticated, determine the WWW-Authenticate header to use for 401 responses, if any.

get_authenticators()#

Instantiates and returns the list of authenticators that this view can use.

get_content_negotiator()#

Instantiate and return the content negotiation class to use.

get_exception_handler()#

Returns the exception handler that this view uses.

get_exception_handler_context()#

Returns a dict that is passed through to EXCEPTION_HANDLER, as the context argument.

get_extra_action_url_map()#

Build a map of {names: urls} for the extra actions.

This method will noop if detail was not provided as a view initkwarg.

classmethod get_extra_actions()#

Get the methods that are marked as an extra ViewSet @action.

get_format_suffix(**kwargs)#

Determine if the request includes a ‘.json’ style format suffix

get_object()#

Returns the object the view is displaying.

You may want to override this if you need to provide non-standard queryset lookups. Eg if objects are referenced using multiple keyword arguments in the url conf.

get_paginated_response(data)#

Return a paginated style Response object for the given output data.

get_parser_context(http_request)#

Returns a dict that is passed through to Parser.parse(), as the parser_context keyword argument.

get_parsers()#

Instantiates and returns the list of parsers that this view can use.

get_permissions()#

Instantiates and returns the list of permissions that this view requires.

get_renderer_context()#

Returns a dict that is passed through to Renderer.render(), as the renderer_context keyword argument.

get_renderers()#

Instantiates and returns the list of renderers that this view can use.

get_serializer(*args, **kwargs)#

Return the serializer instance that should be used for validating and deserializing input, and for serializing output.

get_serializer_context()#

Extra context provided to the serializer class.

get_success_headers(data)#
get_throttles()#

Instantiates and returns the list of throttles that this view uses.

get_view_description(html=False)#

Return some descriptive text for the view, as used in OPTIONS responses and in the browsable API.

get_view_name()#

Return the view name, as used in OPTIONS responses and in the browsable API.

handle_exception(exc)#

Handle any exception that occurs, by returning an appropriate response, or re-raising the error.

http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace']#
http_method_not_allowed(request, *args, **kwargs)#

If request.method does not correspond to a handler method, determine what kind of exception to raise.

initial(request, *args, **kwargs)#

Runs anything that needs to occur prior to calling the method handler.

initialize_request(request, *args, **kwargs)#

Set the .action attribute on the view, depending on the request method.

list(request, *args, **kwargs)#
lookup_field = 'pk'#
lookup_url_kwarg = None#
metadata_class#

alias of SimpleMetadata

name = None#
options(request, *args, **kwargs)#

Handler method for HTTP ‘OPTIONS’ request.

paginate_queryset(queryset)#

Return a single page of results, or None if pagination is disabled.

property paginator#

The paginator instance associated with the view, or None.

parser_classes = [<class 'rest_framework.parsers.JSONParser'>, <class 'rest_framework.parsers.FormParser'>, <class 'rest_framework.parsers.MultiPartParser'>]#
partial_update(request, *args, **kwargs)#
perform_authentication(request)#

Perform authentication on the incoming request.

Note that if you override this and simply ‘pass’, then authentication will instead be performed lazily, the first time either request.user or request.auth is accessed.

perform_content_negotiation(request, force=False)#

Determine which renderer and media type to use render the response.

perform_create(serializer)#
perform_destroy(instance)#
perform_update(serializer)#
permission_denied(request, message=None, code=None)#

If request is not permitted, determine what kind of exception to raise.

raise_uncaught_exception(exc)#
renderer_classes = [<class 'rest_framework.renderers.JSONRenderer'>, <class 'rest_framework.renderers.BrowsableAPIRenderer'>]#
retrieve(request, *args, **kwargs)#
reverse_action(url_name, *args, **kwargs)#

Reverse the action for the given url_name.

schema#
settings = <rest_framework.settings.APISettings object>#
setup(request, *args, **kwargs)#

Initialize attributes shared by all view methods.

suffix = None#
throttle_classes = []#
throttled(request, wait)#

If request is throttled, determine what kind of exception to raise.

update(request, *args, **kwargs)#
versioning_class = None#
view_is_async = False#
class fma_django_api.v1.views.ModelUpdateViewSet(**kwargs)#

Bases: ModelViewSet

The viewset for model updates.

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

pagination_class#

alias of StandardResultsSetPagination

queryset#
permission_classes = [<class 'fma_django_api.v1.permissions.IsClientDeveloperAdmin'>, <class 'fma_django_api.v1.permissions.ClientCreateGetViewPermission'>]#
filterset_fields = ('federated_model', 'status')#
ordering_fields = ('created_on',)#
ordering = ('-created_on',)#
get_serializer_class()#

Returns the ModelUpdate serializer.

Returns the ModelUpdate serializer class depending on if the user is a client or platform user.

Returns:

serializer class for a Federated Model

Return type:

fma_django_api.v1.serializer.ModelSerializer

get_queryset()#

Gets ModelUpdate query_set.

Gets the ModelUpdate query_set based on the REST requested user parameters.

Returns:

ModelUpdate queryset

Return type:

django.db.models.query.QuerySet

perform_create(serializer)#

Saves the current state of the given serializer.

property allowed_methods#

Wrap Django’s private _allowed_methods interface in a public property.

classmethod as_view(actions=None, **initkwargs)#

Because of the way class based views create a closure around the instantiated view, we need to totally reimplement .as_view, and slightly modify the view function that is created and returned.

authentication_classes = [<class 'rest_framework.authentication.BasicAuthentication'>, <class 'rest_framework.authentication.SessionAuthentication'>, <class 'fma_django.authenticators.ClientAuthentication'>, <class 'rest_framework.authentication.TokenAuthentication'>]#
basename = None#
check_object_permissions(request, obj)#

Check if the request should be permitted for a given object. Raises an appropriate exception if the request is not permitted.

check_permissions(request)#

Check if the request should be permitted. Raises an appropriate exception if the request is not permitted.

check_throttles(request)#

Check if request should be throttled. Raises an appropriate exception if the request is throttled.

content_negotiation_class#

alias of DefaultContentNegotiation

create(request, *args, **kwargs)#
property default_response_headers#
description = None#
destroy(request, *args, **kwargs)#
detail = None#
determine_version(request, *args, **kwargs)#

If versioning is being used, then determine any API version for the incoming request. Returns a two-tuple of (version, versioning_scheme)

dispatch(request, *args, **kwargs)#

.dispatch() is pretty much the same as Django’s regular dispatch, but with extra hooks for startup, finalize, and exception handling.

filter_backends = [<class 'django_filters.rest_framework.backends.DjangoFilterBackend'>, <class 'rest_framework.filters.OrderingFilter'>]#
filter_queryset(queryset)#

Given a queryset, filter it with whichever filter backend is in use.

You are unlikely to want to override this method, although you may need to call it either from a list view, or from a custom get_object method if you want to apply the configured filtering backend to the default queryset.

finalize_response(request, response, *args, **kwargs)#

Returns the final response object.

get_authenticate_header(request)#

If a request is unauthenticated, determine the WWW-Authenticate header to use for 401 responses, if any.

get_authenticators()#

Instantiates and returns the list of authenticators that this view can use.

get_content_negotiator()#

Instantiate and return the content negotiation class to use.

get_exception_handler()#

Returns the exception handler that this view uses.

get_exception_handler_context()#

Returns a dict that is passed through to EXCEPTION_HANDLER, as the context argument.

get_extra_action_url_map()#

Build a map of {names: urls} for the extra actions.

This method will noop if detail was not provided as a view initkwarg.

classmethod get_extra_actions()#

Get the methods that are marked as an extra ViewSet @action.

get_format_suffix(**kwargs)#

Determine if the request includes a ‘.json’ style format suffix

get_object()#

Returns the object the view is displaying.

You may want to override this if you need to provide non-standard queryset lookups. Eg if objects are referenced using multiple keyword arguments in the url conf.

get_paginated_response(data)#

Return a paginated style Response object for the given output data.

get_parser_context(http_request)#

Returns a dict that is passed through to Parser.parse(), as the parser_context keyword argument.

get_parsers()#

Instantiates and returns the list of parsers that this view can use.

get_permissions()#

Instantiates and returns the list of permissions that this view requires.

get_renderer_context()#

Returns a dict that is passed through to Renderer.render(), as the renderer_context keyword argument.

get_renderers()#

Instantiates and returns the list of renderers that this view can use.

get_serializer(*args, **kwargs)#

Return the serializer instance that should be used for validating and deserializing input, and for serializing output.

get_serializer_context()#

Extra context provided to the serializer class.

get_success_headers(data)#
get_throttles()#

Instantiates and returns the list of throttles that this view uses.

get_view_description(html=False)#

Return some descriptive text for the view, as used in OPTIONS responses and in the browsable API.

get_view_name()#

Return the view name, as used in OPTIONS responses and in the browsable API.

handle_exception(exc)#

Handle any exception that occurs, by returning an appropriate response, or re-raising the error.

http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace']#
http_method_not_allowed(request, *args, **kwargs)#

If request.method does not correspond to a handler method, determine what kind of exception to raise.

initial(request, *args, **kwargs)#

Runs anything that needs to occur prior to calling the method handler.

initialize_request(request, *args, **kwargs)#

Set the .action attribute on the view, depending on the request method.

list(request, *args, **kwargs)#
lookup_field = 'pk'#
lookup_url_kwarg = None#
metadata_class#

alias of SimpleMetadata

name = None#
options(request, *args, **kwargs)#

Handler method for HTTP ‘OPTIONS’ request.

paginate_queryset(queryset)#

Return a single page of results, or None if pagination is disabled.

property paginator#

The paginator instance associated with the view, or None.

parser_classes = [<class 'rest_framework.parsers.JSONParser'>, <class 'rest_framework.parsers.FormParser'>, <class 'rest_framework.parsers.MultiPartParser'>]#
partial_update(request, *args, **kwargs)#
perform_authentication(request)#

Perform authentication on the incoming request.

Note that if you override this and simply ‘pass’, then authentication will instead be performed lazily, the first time either request.user or request.auth is accessed.

perform_content_negotiation(request, force=False)#

Determine which renderer and media type to use render the response.

perform_destroy(instance)#
perform_update(serializer)#
permission_denied(request, message=None, code=None)#

If request is not permitted, determine what kind of exception to raise.

raise_uncaught_exception(exc)#
renderer_classes = [<class 'rest_framework.renderers.JSONRenderer'>, <class 'rest_framework.renderers.BrowsableAPIRenderer'>]#
retrieve(request, *args, **kwargs)#
reverse_action(url_name, *args, **kwargs)#

Reverse the action for the given url_name.

schema#
serializer_class = None#
settings = <rest_framework.settings.APISettings object>#
setup(request, *args, **kwargs)#

Initialize attributes shared by all view methods.

suffix = None#
throttle_classes = []#
throttled(request, wait)#

If request is throttled, determine what kind of exception to raise.

update(request, *args, **kwargs)#
versioning_class = None#
view_is_async = False#
class fma_django_api.v1.views.ModelAggregateViewSet(**kwargs)#

Bases: ModelViewSet

The viewset for model aggregates.

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

serializer_class#

alias of ModelAggregateSerializer

pagination_class#

alias of StandardResultsSetPagination

queryset#
permission_classes = [<class 'fma_django_api.v1.permissions.IsClientDeveloperAdmin'>, <class 'fma_django_api.v1.permissions.ClientViewOnlyPermission'>]#
filterset_fields = ('federated_model',)#
ordering_fields = ('created_on', 'validation_score')#
ordering = ('-created_on',)#
get_queryset()#

Get the ModelAggregate queryset.

Gets the ModelAggregate queryset based on the REST requested user parameters.

Returns:

ModelAggregate queryset

retrieve(request, *args, **kwargs)#

Returns a Response containing serialized data about the given aggregate.

Parameters:
  • request (Any) – Message from client asking for the current instance of the ModelAggregateViewSet

  • args (Dict, optional) – Arguments

  • kwargs (Dict, optional) – Keyword argumets

Returns:

Serialized data about the model aggregate

Return type:

Response

publish_aggregate(request, *args, **kwargs)#

Publish aggregate from passed in ID.

Parameters:
  • request (Any) – A message containing data about a model aggregate

  • args (Dict, optional) – Arguments

  • kwargs (Dict, optional) – Keyword arguments

Returns:

Serialized data about the published aggregate (artifact)

Return type:

Response

property allowed_methods#

Wrap Django’s private _allowed_methods interface in a public property.

classmethod as_view(actions=None, **initkwargs)#

Because of the way class based views create a closure around the instantiated view, we need to totally reimplement .as_view, and slightly modify the view function that is created and returned.

authentication_classes = [<class 'rest_framework.authentication.BasicAuthentication'>, <class 'rest_framework.authentication.SessionAuthentication'>, <class 'fma_django.authenticators.ClientAuthentication'>, <class 'rest_framework.authentication.TokenAuthentication'>]#
basename = None#
check_object_permissions(request, obj)#

Check if the request should be permitted for a given object. Raises an appropriate exception if the request is not permitted.

check_permissions(request)#

Check if the request should be permitted. Raises an appropriate exception if the request is not permitted.

check_throttles(request)#

Check if request should be throttled. Raises an appropriate exception if the request is throttled.

content_negotiation_class#

alias of DefaultContentNegotiation

create(request, *args, **kwargs)#
property default_response_headers#
description = None#
destroy(request, *args, **kwargs)#
detail = None#
determine_version(request, *args, **kwargs)#

If versioning is being used, then determine any API version for the incoming request. Returns a two-tuple of (version, versioning_scheme)

dispatch(request, *args, **kwargs)#

.dispatch() is pretty much the same as Django’s regular dispatch, but with extra hooks for startup, finalize, and exception handling.

filter_backends = [<class 'django_filters.rest_framework.backends.DjangoFilterBackend'>, <class 'rest_framework.filters.OrderingFilter'>]#
filter_queryset(queryset)#

Given a queryset, filter it with whichever filter backend is in use.

You are unlikely to want to override this method, although you may need to call it either from a list view, or from a custom get_object method if you want to apply the configured filtering backend to the default queryset.

finalize_response(request, response, *args, **kwargs)#

Returns the final response object.

get_authenticate_header(request)#

If a request is unauthenticated, determine the WWW-Authenticate header to use for 401 responses, if any.

get_authenticators()#

Instantiates and returns the list of authenticators that this view can use.

get_content_negotiator()#

Instantiate and return the content negotiation class to use.

get_exception_handler()#

Returns the exception handler that this view uses.

get_exception_handler_context()#

Returns a dict that is passed through to EXCEPTION_HANDLER, as the context argument.

get_extra_action_url_map()#

Build a map of {names: urls} for the extra actions.

This method will noop if detail was not provided as a view initkwarg.

classmethod get_extra_actions()#

Get the methods that are marked as an extra ViewSet @action.

get_format_suffix(**kwargs)#

Determine if the request includes a ‘.json’ style format suffix

get_object()#

Returns the object the view is displaying.

You may want to override this if you need to provide non-standard queryset lookups. Eg if objects are referenced using multiple keyword arguments in the url conf.

get_paginated_response(data)#

Return a paginated style Response object for the given output data.

get_parser_context(http_request)#

Returns a dict that is passed through to Parser.parse(), as the parser_context keyword argument.

get_parsers()#

Instantiates and returns the list of parsers that this view can use.

get_permissions()#

Instantiates and returns the list of permissions that this view requires.

get_renderer_context()#

Returns a dict that is passed through to Renderer.render(), as the renderer_context keyword argument.

get_renderers()#

Instantiates and returns the list of renderers that this view can use.

get_serializer(*args, **kwargs)#

Return the serializer instance that should be used for validating and deserializing input, and for serializing output.

get_serializer_class()#

Return the class to use for the serializer. Defaults to using self.serializer_class.

You may want to override this if you need to provide different serializations depending on the incoming request.

(Eg. admins get full serialization, others get basic serialization)

get_serializer_context()#

Extra context provided to the serializer class.

get_success_headers(data)#
get_throttles()#

Instantiates and returns the list of throttles that this view uses.

get_view_description(html=False)#

Return some descriptive text for the view, as used in OPTIONS responses and in the browsable API.

get_view_name()#

Return the view name, as used in OPTIONS responses and in the browsable API.

handle_exception(exc)#

Handle any exception that occurs, by returning an appropriate response, or re-raising the error.

http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace']#
http_method_not_allowed(request, *args, **kwargs)#

If request.method does not correspond to a handler method, determine what kind of exception to raise.

initial(request, *args, **kwargs)#

Runs anything that needs to occur prior to calling the method handler.

initialize_request(request, *args, **kwargs)#

Set the .action attribute on the view, depending on the request method.

list(request, *args, **kwargs)#
lookup_field = 'pk'#
lookup_url_kwarg = None#
metadata_class#

alias of SimpleMetadata

name = None#
options(request, *args, **kwargs)#

Handler method for HTTP ‘OPTIONS’ request.

paginate_queryset(queryset)#

Return a single page of results, or None if pagination is disabled.

property paginator#

The paginator instance associated with the view, or None.

parser_classes = [<class 'rest_framework.parsers.JSONParser'>, <class 'rest_framework.parsers.FormParser'>, <class 'rest_framework.parsers.MultiPartParser'>]#
partial_update(request, *args, **kwargs)#
perform_authentication(request)#

Perform authentication on the incoming request.

Note that if you override this and simply ‘pass’, then authentication will instead be performed lazily, the first time either request.user or request.auth is accessed.

perform_content_negotiation(request, force=False)#

Determine which renderer and media type to use render the response.

perform_create(serializer)#
perform_destroy(instance)#
perform_update(serializer)#
permission_denied(request, message=None, code=None)#

If request is not permitted, determine what kind of exception to raise.

raise_uncaught_exception(exc)#
renderer_classes = [<class 'rest_framework.renderers.JSONRenderer'>, <class 'rest_framework.renderers.BrowsableAPIRenderer'>]#
reverse_action(url_name, *args, **kwargs)#

Reverse the action for the given url_name.

schema#
settings = <rest_framework.settings.APISettings object>#
setup(request, *args, **kwargs)#

Initialize attributes shared by all view methods.

suffix = None#
throttle_classes = []#
throttled(request, wait)#

If request is throttled, determine what kind of exception to raise.

update(request, *args, **kwargs)#
versioning_class = None#
view_is_async = False#
class fma_django_api.v1.views.ClientAggregateScoreViewSet(**kwargs)#

Bases: ModelViewSet

The viewset for client aggregate scores.

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

queryset#
pagination_class#

alias of StandardResultsSetPagination

serializer_class#

alias of ClientAggregateScoreSerializer

permission_classes = [<class 'fma_django_api.v1.permissions.IsClientDeveloperAdmin'>, <class 'fma_django_api.v1.permissions.ClientCreateGetViewPermission'>]#
filterset_fields = ('aggregate', 'client')#
ordering_fields = ('created_on',)#
ordering = ('-created_on',)#
get_queryset()#

Gets the ClientAggregateScore query_set.

Gets the ClientAggregateScore query_set based on the REST requested user parameters.

Returns:

ClientAggregateScore queryset

perform_create(serializer)#

Saves the current state of the given serializer.

property allowed_methods#

Wrap Django’s private _allowed_methods interface in a public property.

classmethod as_view(actions=None, **initkwargs)#

Because of the way class based views create a closure around the instantiated view, we need to totally reimplement .as_view, and slightly modify the view function that is created and returned.

authentication_classes = [<class 'rest_framework.authentication.BasicAuthentication'>, <class 'rest_framework.authentication.SessionAuthentication'>, <class 'fma_django.authenticators.ClientAuthentication'>, <class 'rest_framework.authentication.TokenAuthentication'>]#
basename = None#
check_object_permissions(request, obj)#

Check if the request should be permitted for a given object. Raises an appropriate exception if the request is not permitted.

check_permissions(request)#

Check if the request should be permitted. Raises an appropriate exception if the request is not permitted.

check_throttles(request)#

Check if request should be throttled. Raises an appropriate exception if the request is throttled.

content_negotiation_class#

alias of DefaultContentNegotiation

create(request, *args, **kwargs)#
property default_response_headers#
description = None#
destroy(request, *args, **kwargs)#
detail = None#
determine_version(request, *args, **kwargs)#

If versioning is being used, then determine any API version for the incoming request. Returns a two-tuple of (version, versioning_scheme)

dispatch(request, *args, **kwargs)#

.dispatch() is pretty much the same as Django’s regular dispatch, but with extra hooks for startup, finalize, and exception handling.

filter_backends = [<class 'django_filters.rest_framework.backends.DjangoFilterBackend'>, <class 'rest_framework.filters.OrderingFilter'>]#
filter_queryset(queryset)#

Given a queryset, filter it with whichever filter backend is in use.

You are unlikely to want to override this method, although you may need to call it either from a list view, or from a custom get_object method if you want to apply the configured filtering backend to the default queryset.

finalize_response(request, response, *args, **kwargs)#

Returns the final response object.

get_authenticate_header(request)#

If a request is unauthenticated, determine the WWW-Authenticate header to use for 401 responses, if any.

get_authenticators()#

Instantiates and returns the list of authenticators that this view can use.

get_content_negotiator()#

Instantiate and return the content negotiation class to use.

get_exception_handler()#

Returns the exception handler that this view uses.

get_exception_handler_context()#

Returns a dict that is passed through to EXCEPTION_HANDLER, as the context argument.

get_extra_action_url_map()#

Build a map of {names: urls} for the extra actions.

This method will noop if detail was not provided as a view initkwarg.

classmethod get_extra_actions()#

Get the methods that are marked as an extra ViewSet @action.

get_format_suffix(**kwargs)#

Determine if the request includes a ‘.json’ style format suffix

get_object()#

Returns the object the view is displaying.

You may want to override this if you need to provide non-standard queryset lookups. Eg if objects are referenced using multiple keyword arguments in the url conf.

get_paginated_response(data)#

Return a paginated style Response object for the given output data.

get_parser_context(http_request)#

Returns a dict that is passed through to Parser.parse(), as the parser_context keyword argument.

get_parsers()#

Instantiates and returns the list of parsers that this view can use.

get_permissions()#

Instantiates and returns the list of permissions that this view requires.

get_renderer_context()#

Returns a dict that is passed through to Renderer.render(), as the renderer_context keyword argument.

get_renderers()#

Instantiates and returns the list of renderers that this view can use.

get_serializer(*args, **kwargs)#

Return the serializer instance that should be used for validating and deserializing input, and for serializing output.

get_serializer_class()#

Return the class to use for the serializer. Defaults to using self.serializer_class.

You may want to override this if you need to provide different serializations depending on the incoming request.

(Eg. admins get full serialization, others get basic serialization)

get_serializer_context()#

Extra context provided to the serializer class.

get_success_headers(data)#
get_throttles()#

Instantiates and returns the list of throttles that this view uses.

get_view_description(html=False)#

Return some descriptive text for the view, as used in OPTIONS responses and in the browsable API.

get_view_name()#

Return the view name, as used in OPTIONS responses and in the browsable API.

handle_exception(exc)#

Handle any exception that occurs, by returning an appropriate response, or re-raising the error.

http_method_names = ['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace']#
http_method_not_allowed(request, *args, **kwargs)#

If request.method does not correspond to a handler method, determine what kind of exception to raise.

initial(request, *args, **kwargs)#

Runs anything that needs to occur prior to calling the method handler.

initialize_request(request, *args, **kwargs)#

Set the .action attribute on the view, depending on the request method.

list(request, *args, **kwargs)#
lookup_field = 'pk'#
lookup_url_kwarg = None#
metadata_class#

alias of SimpleMetadata

name = None#
options(request, *args, **kwargs)#

Handler method for HTTP ‘OPTIONS’ request.

paginate_queryset(queryset)#

Return a single page of results, or None if pagination is disabled.

property paginator#

The paginator instance associated with the view, or None.

parser_classes = [<class 'rest_framework.parsers.JSONParser'>, <class 'rest_framework.parsers.FormParser'>, <class 'rest_framework.parsers.MultiPartParser'>]#
partial_update(request, *args, **kwargs)#
perform_authentication(request)#

Perform authentication on the incoming request.

Note that if you override this and simply ‘pass’, then authentication will instead be performed lazily, the first time either request.user or request.auth is accessed.

perform_content_negotiation(request, force=False)#

Determine which renderer and media type to use render the response.

perform_destroy(instance)#
perform_update(serializer)#
permission_denied(request, message=None, code=None)#

If request is not permitted, determine what kind of exception to raise.

raise_uncaught_exception(exc)#
renderer_classes = [<class 'rest_framework.renderers.JSONRenderer'>, <class 'rest_framework.renderers.BrowsableAPIRenderer'>]#
retrieve(request, *args, **kwargs)#
reverse_action(url_name, *args, **kwargs)#

Reverse the action for the given url_name.

schema#
settings = <rest_framework.settings.APISettings object>#
setup(request, *args, **kwargs)#

Initialize attributes shared by all view methods.

suffix = None#
throttle_classes = []#
throttled(request, wait)#

If request is throttled, determine what kind of exception to raise.

update(request, *args, **kwargs)#
versioning_class = None#
view_is_async = False#