Smarter Authenticated API View

class smarter.lib.drf.views.token_authentication_helpers.SmarterAuthenticatedAPIView(*args, **kwargs)[source]

Bases: APIView, SmarterRequestMixin

Smarter base class for DRF API detail views that require authentication.

Does the following:

  • Adds SmarterRequestMixin to the view, so that base Smarter functionality is available to all subclasses.

  • Adds SmarterTokenAuthentication to the default SessionAuthentication for authentication.

  • Overrides Django’s logic for initializing the request object to ensure that SmarterRequestMixin is fully initialized before any other logic runs.

__init__(*args, **kwargs)[source]

Initialize the SmarterAuthenticatedAPIView.

authentication_classes = [<class 'smarter.lib.drf.token_authentication.SmarterTokenAuthentication'>, <class 'rest_framework.authentication.SessionAuthentication'>]
property formatted_class_name

Helper method to get the formatted class name for logging.

initial(request, *args, **kwargs)[source]

Extend initial() DRF view method. Initialize the view with the request and any additional arguments.

This is the earliest point in the DRF view lifecycle where the request object is available. Up to this point our SmarterRequestMixin, and AccountMixin classes are only partially initialized. This method takes care of the rest of the initialization.

Parameters:

request (HttpRequest) – The incoming HTTP request.

permission_classes = [<class 'smarter.lib.drf.views.helpers.SmarterAuthenticatedPermissionClass'>]
setup(request, *args, **kwargs)[source]

Extend setup() DRF view method. Setup the view. This is called by Django before dispatch() and is used to set up the view for the request.

Parameters:

request (HttpRequest) – The incoming HTTP request.