How to update 'Allow' headers in DRF to match an OPTIONS request's permissions? #9059
-
I am using Django Rest Framework 3.14 with ModelViewsets and a settings-wide DjangoModelOrAnonReadOnly permission class. I am trying to add custom HTTP headers to my responses to OPTIONS request, so as reflect the authentication/permission of the requesting party, like so: def options(self, request, *args, **kwargs) -> response.Response:
allowed_actions = self.metadata_class().determine_actions(request, self)
allowed_actions = ", ".join(allowed_actions.keys())
data = self.metadata_class().determine_metadata(request, self)
return response.Response(data, headers={"Allow": allowed_actions}) Alas, the |
Beta Was this translation helpful? Give feedback.
Answered by
why-not-try-calmer
Aug 2, 2023
Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
why-not-try-calmer
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://stackoverflow.com/a/76808421/4500155