code: def get_relation_routes(self, viewset):
          
  
          routes = []
  
          if not hasattr(viewset, 'serializer_class'):
              return routes
          if not hasattr(viewset, 'list_related'):
              return routes
  
          serializer = viewset.serializer_class()
          fields = getattr(serializer, 'get_link_fields', lambda: [])()
  
          route_name = '{basename}-{methodnamehyphen}'
  
          for field_name, field in six.iteritems(fields):
              methodname = 'list_related'
              url = (
                  r'^{prefix}/{lookup}/(?P<field_name>%s)'
                  '{trailing_slash}$' % field_name
              )
              routes.append(Route(
                  url=url,
                  mapping={'get': methodname},
                  name=replace_methodname(route_name, field_name),
                  initkwargs={}
              ))
          return routes
docs: Generate routes to serve relational objects. This method will add
          a sub-URL for each relational field.
  
          e.g.
          A viewset for the following serializer:
  
            class UserSerializer(..):
                events = DynamicRelationField(EventSerializer, many=True)
                groups = DynamicRelationField(GroupSerializer, many=True)
                location = DynamicRelationField(LocationSerializer)
  
          will have the following URLs added:
  
            /users/<pk>/events/
            /users/<pk>/groups/
            /users/<pk>/location/