Smarter Authenticated List API View

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

Bases: ListAPIView, SmarterRequestMixin

Smarter base class for DRF API list 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 SmarterAuthenticatedListAPIView.

Unlike SmarterAuthenticatedAPIView, this class previously had no __init__ override. DRF/Django’s View.__init__ does not call super().__init__(), so without this, SmarterRequestMixin.__init__() (and thus self._srm_ready and friends) was never invoked, causing an AttributeError the first time self.srm_ready was accessed.

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.

get_permissions()[source]

OPTIONS requests (CORS preflight, DRF metadata probes) never carry credentials.

Don’t require authentication for them.

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

Extend DRF initial() to add SmarterRequestMixin.

Parameters:

request (Request) – The incoming HTTP request.

permission_classes = [<class 'smarter.lib.drf.views.helpers.SmarterAuthenticatedPermissionClass'>]