'Create fields for forward and reverse relationships.'

def build_relational_field(self, field_name, relation_info):

    field_class = self.serializer_related_field
    field_kwargs = get_relation_kwargs(field_name, relation_info)
    to_field = field_kwargs.pop(u'to_field', None)
    if (to_field and (not relation_info.reverse) and (not relation_info.related_model._meta.get_field(to_field).primary_key)):
        field_kwargs[u'slug_field'] = to_field
        field_class = self.serializer_related_to_field
    if (not issubclass(field_class, HyperlinkedRelatedField)):
        field_kwargs.pop(u'view_name', None)
    return (field_class, field_kwargs)
