Unable to use self.action in custom get_authenticators() method #9409
Unanswered
SpecLad
asked this question in
Potential Issue
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'd like to vary the authenticators used by a viewset depending on the current action. However,
self.action
is not set whileget_authenticators()
is executed. This is because of the following logic inViewSetMixin.initialize_request
:django-rest-framework/rest_framework/viewsets.py
Lines 145 to 153 in 36d5c0e
get_authentication()
is called insuper().initialize_request()
beforeself.action
is assigned.I think this could be fixed trivially by moving the
super().initialize_request()
call after theself.action
assignment. You only need to know the request method to determine the value forself.action
, which is already available beforesuper().initialize_request()
. Would you consider doing this?Beta Was this translation helpful? Give feedback.
All reactions