You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As discussed in #5 a DynamicFieldMixin-ed serializer that accesses context will fail when used as a nested serializer.
I found this issue when I was re-using a serializer as a nested serializer, and that serializer relies on context['request'] to build a url for one of its fields.
Without fixing drf-dynamic-fields to allow nested serializers, there are a number of work arounds:
You could just have two separate serializers, one for nesting and one for normal views.
The nested serializer can manually find the correct context by chasing the parent fields up the tree until it finds the one with context set.
I used 2) for a while before deciding it was better to fix the underlying issue.
The text was updated successfully, but these errors were encountered:
As discussed in #5 a DynamicFieldMixin-ed serializer that accesses
context
will fail when used as a nested serializer.I found this issue when I was re-using a serializer as a nested serializer, and that serializer relies on
context['request']
to build a url for one of its fields.Without fixing
drf-dynamic-fields
to allow nested serializers, there are a number of work arounds:context
by chasing theparent
fields up the tree until it finds the one withcontext
set.I used 2) for a while before deciding it was better to fix the underlying issue.
The text was updated successfully, but these errors were encountered: