Suppose we have this urlpattern /<int:school_id>/courses and we wanna access school in the serializer ( I know that we can do self.context['view'].kwargs['school_id'])
But would it be possible to have it as a serializer field?
Something like this:
class CourseSerializer(serializers.Serializer):
school = serializers.RouteParameter(name='school_id', queryset=School.objects.all())
....
Suppose we have this urlpattern
/<int:school_id>/coursesand we wanna accessschoolin the serializer ( I know that we can doself.context['view'].kwargs['school_id'])But would it be possible to have it as a serializer field?
Something like this: