code: def ordering_for(self, term, view):
          
          if not self._is_allowed_term(term, view):
              return None
  
          serializer = self._get_serializer_class(view)()
          serializer_chain = term.split('.')
  
          model_chain = []
  
          for segment in serializer_chain[:-1]:
              field = serializer.get_all_fields().get(segment)
  
              if not (field and field.source != '*' and
                      isinstance(field, DynamicRelationField)):
                  return None
  
              model_chain.append(field.source or segment)
  
              serializer = field.serializer_class()
  
          last_segment = serializer_chain[-1]
          last_field = serializer.get_all_fields().get(last_segment)
  
          if not last_field or last_field.source == '*':
              return None
  
          model_chain.append(last_field.source or last_segment)
  
          return '__'.join(model_chain)
docs: Return ordering (model field chain) for term (serializer field chain)
          or None if invalid
  
          Raise ImproperlyConfigured if serializer_class not set on view