mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-25 19:14:01 +03:00
Merge branch 'master' of github.com:tomchristie/django-rest-framework
This commit is contained in:
commit
f9df0dc965
|
@ -955,3 +955,24 @@ class TestMetaInheritance(TestCase):
|
|||
self.assertEqual(unicode_repr(ChildSerializer()), child_expected)
|
||||
self.assertEqual(unicode_repr(TestSerializer()), test_expected)
|
||||
self.assertEqual(unicode_repr(ChildSerializer()), child_expected)
|
||||
|
||||
|
||||
class OneToOneTargetTestModel(models.Model):
|
||||
text = models.CharField(max_length=100)
|
||||
|
||||
|
||||
class OneToOneSourceTestModel(models.Model):
|
||||
target = models.OneToOneField(OneToOneTargetTestModel, primary_key=True)
|
||||
|
||||
|
||||
class TestModelFieldValues(TestCase):
|
||||
def test_model_field(self):
|
||||
class ExampleSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = OneToOneSourceTestModel
|
||||
fields = ('target',)
|
||||
|
||||
target = OneToOneTargetTestModel(id=1, text='abc')
|
||||
source = OneToOneSourceTestModel(target=target)
|
||||
serializer = ExampleSerializer(source)
|
||||
self.assertEqual(serializer.data, {'target': 1})
|
||||
|
|
Loading…
Reference in New Issue
Block a user