      def get_nested_field(self, model_field, rel=None):
          """
          Creates a default instance of a nested relational field.
          """
          class NestedModelSerializer(ModelSerializer):
              class Meta:
                  model = model_class
          return NestedModelSerializer()
  
 
</s> remove     def get_nested_field(self, model_field):
 </s> add     def get_nested_field(self, model_field, rel=None): </s> remove                 model = model_field.rel.to
 </s> add                 model = model_class </s> remove     def get_related_field(self, model_field, to_many=False):
 </s> add     def get_related_field(self, model_field, rel=None, to_many=False): </s> remove         return None
 </s> add         if self.opts.fields and model_field.name in self.opts.fields:
            return self.get_field(model_field)
        if rel:
            model_class = rel.model
        else:
            model_class = model_field.rel.to

      def get_nested_field(self, model_field, rel=None):
          """
          Creates a default instance of a nested relational field.
          """
        if rel:
            model_class = rel.model
        else:
            model_class = model_field.rel.to

          class NestedModelSerializer(ModelSerializer):
              class Meta:
                  model = model_class
          return NestedModelSerializer()
  
keep keep keep add keep keep keep keep keep
 First pass on automatically including reverse relationship 
rest_framework/serializers.py