  from rest_framework import serializers
  
  
  # Models for testing regular field mapping
  
  class RegularFieldsModel(models.Model):
      auto_field = models.AutoField(primary_key=True)
 
</s> remove REGULAR_FIELDS_REPR = """
TestSerializer():
    auto_field = IntegerField(read_only=True)
    big_integer_field = IntegerField()
    boolean_field = BooleanField(default=False)
    char_field = CharField(max_length=100)
    comma_seperated_integer_field = CharField(max_length=100, validators=[<django.core.validators.RegexValidator object>])
    date_field = DateField()
    datetime_field = DateTimeField()
    decimal_field = DecimalField(decimal_places=1, max_digits=3)
    email_field = EmailField(max_length=100)
    float_field = FloatField()
    integer_field = IntegerField()
    null_boolean_field = BooleanField(required=False)
    positive_integer_field = IntegerField()
    positive_small_integer_field = IntegerField()
    slug_field = SlugField(max_length=100)
    small_integer_field = IntegerField()
    text_field = CharField()
    time_field = TimeField()
    url_field = URLField(max_length=100)
""".strip()
 </s> add class TestRegularFieldMappings(TestCase):
    def test_regular_fields(self):
        class TestSerializer(serializers.ModelSerializer):
            class Meta:
                model = RegularFieldsModel

        expected = dedent("""
            TestSerializer():
                auto_field = IntegerField(read_only=True)
                big_integer_field = IntegerField()
                boolean_field = BooleanField(default=False)
                char_field = CharField(max_length=100)
                comma_seperated_integer_field = CharField(max_length=100, validators=[<django.core.validators.RegexValidator object>])
                date_field = DateField()
                datetime_field = DateTimeField()
                decimal_field = DecimalField(decimal_places=1, max_digits=3)
                email_field = EmailField(max_length=100)
                float_field = FloatField()
                integer_field = IntegerField()
                null_boolean_field = BooleanField(required=False)
                positive_integer_field = IntegerField()
                positive_small_integer_field = IntegerField()
                slug_field = SlugField(max_length=100)
                small_integer_field = IntegerField()
                text_field = CharField()
                time_field = TimeField()
                url_field = URLField(max_length=100)
        """)

        self.assertEqual(repr(TestSerializer()), expected) </s> remove         self.assertEqual(repr(TestSerializer()), HYPERLINKED_NESTED_REPR)
 </s> add         expected = dedent("""
            TestSerializer():
                url = HyperlinkedIdentityField(view_name='relationalmodel-detail')
                foreign_key = NestedModelSerializer(read_only=True):
                    id = IntegerField(label='ID', read_only=True)
                    name = CharField(max_length=100)
                one_to_one = NestedModelSerializer(read_only=True):
                    id = IntegerField(label='ID', read_only=True)
                    name = CharField(max_length=100)
                many_to_many = NestedModelSerializer(many=True, read_only=True):
                    id = IntegerField(label='ID', read_only=True)
                    name = CharField(max_length=100)
            """)
        self.assertEqual(repr(TestSerializer()), expected) </s> remove         self.assertEqual(repr(TestSerializer()), RELATIONAL_FLAT_REPR)
 </s> add         expected = dedent("""
            TestSerializer():
                id = IntegerField(label='ID', read_only=True)
                foreign_key = PrimaryKeyRelatedField(queryset=ForeignKeyTargetModel.objects.all())
                one_to_one = PrimaryKeyRelatedField(queryset=OneToOneTargetModel.objects.all())
                many_to_many = PrimaryKeyRelatedField(many=True, queryset=ManyToManyTargetModel.objects.all())
        """)
        self.assertEqual(repr(TestSerializer()), expected) </s> remove         self.assertEqual(repr(TestSerializer()), HYPERLINKED_FLAT_REPR)
 </s> add         expected = dedent("""
            TestSerializer():
                url = HyperlinkedIdentityField(view_name='relationalmodel-detail')
                foreign_key = HyperlinkedRelatedField(queryset=ForeignKeyTargetModel.objects.all(), view_name='foreignkeytargetmodel-detail')
                one_to_one = HyperlinkedRelatedField(queryset=OneToOneTargetModel.objects.all(), view_name='onetoonetargetmodel-detail')
                many_to_many = HyperlinkedRelatedField(many=True, queryset=ManyToManyTargetModel.objects.all(), view_name='manytomanytargetmodel-detail')
        """)
        self.assertEqual(repr(TestSerializer()), expected) </s> remove         self.assertEqual(repr(TestSerializer()), RELATIONAL_NESTED_REPR)
 </s> add         expected = dedent("""
            TestSerializer():
                id = IntegerField(label='ID', read_only=True)
                foreign_key = NestedModelSerializer(read_only=True):
                    id = IntegerField(label='ID', read_only=True)
                    name = CharField(max_length=100)
                one_to_one = NestedModelSerializer(read_only=True):
                    id = IntegerField(label='ID', read_only=True)
                    name = CharField(max_length=100)
                many_to_many = NestedModelSerializer(many=True, read_only=True):
                    id = IntegerField(label='ID', read_only=True)
                    name = CharField(max_length=100)
        """)
        self.assertEqual(repr(TestSerializer()), expected)
def dedent(blocktext):
    return '\n'.join([line[12:] for line in blocktext.splitlines()[1:-1]])


  from rest_framework import serializers
  
  
def dedent(blocktext):
    return '\n'.join([line[12:] for line in blocktext.splitlines()[1:-1]])


  # Models for testing regular field mapping
  
  class RegularFieldsModel(models.Model):
      auto_field = models.AutoField(primary_key=True)
keep keep add keep keep keep keep
 Clean up field mapping tests 
tests/test_model_field_mappings.py