Smarter Authenticated List API View
- class smarter.lib.drf.views.token_authentication_helpers.SmarterAuthenticatedListAPIView(*args, **kwargs)[source]
Bases:
ListAPIView,SmarterRequestMixinSmarter 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 view, and its SmarterRequestMixin.
DRF/Django’s
View.__init__()does not callsuper().__init__(), so without this,SmarterRequestMixin.__init__()(and thusself._srm_readyand friends) would never be invoked, causing an AttributeError the first timeself.srm_readyis accessed.- Parameters:
args – Passed to the view and to SmarterRequestMixin.
kwargs – Passed to the view.
request,user,accountanduser_profileare passed to SmarterRequestMixin.
- authentication_classes = [<class 'smarter.lib.drf.token_authentication.SmarterTokenAuthentication'>, <class 'rest_framework.authentication.SessionAuthentication'>]
- get_permissions()[source]
Return the view’s permissions, none for an OPTIONS request.
OPTIONS requests (CORS preflight, DRF metadata probes) never carry credentials, so they don’t require authentication.
- Returns:
The permission instances, or an empty list for an OPTIONS request.
- initial(request, *args, **kwargs)[source]
Set the SmarterRequestMixin’s request to the DRF request, then run DRF’s
initial().- Parameters:
request (
Request) – The incoming HTTP request.args – Passed to DRF’s
initial().kwargs – Passed to DRF’s
initial().
- permission_classes = [<class 'smarter.lib.drf.views.helpers.SmarterAuthenticatedPermissionClass'>]