a request context in the output schema #1143
Answered
by
vitalik
jankrnavek
asked this question in
Q&A
-
Hi, Thank, |
Beta Was this translation helpful? Give feedback.
Answered by
vitalik
Apr 29, 2024
Replies: 1 comment
-
sure - https://django-ninja.dev/guides/response/?h=resolve_#accessing-extra-context class Some(Schema):
...
my_fields: list[User] = []
@staticmethod
def resolve_my_fields(obj, context):
request = context["request"]
user = request.user
return user.friends.all() |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
jankrnavek
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jankrnavek
sure - https://django-ninja.dev/guides/response/?h=resolve_#accessing-extra-context