mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-03 03:50:11 +03:00
Add test to reproduce a raise when using field with source parameter containing "."
This commit is contained in:
parent
551fe92078
commit
dd39a29b7e
|
@ -547,6 +547,20 @@ class ModelValidationTests(TestCase):
|
||||||
self.assertTrue(photo_serializer.is_valid())
|
self.assertTrue(photo_serializer.is_valid())
|
||||||
self.assertTrue(photo_serializer.save())
|
self.assertTrue(photo_serializer.save())
|
||||||
|
|
||||||
|
def test_foreign_key_with_dot_notation_fields(self):
|
||||||
|
album = Album(title='test')
|
||||||
|
album.save()
|
||||||
|
|
||||||
|
class PhotoSerializer(serializers.ModelSerializer):
|
||||||
|
album_title = serializers.CharField(source="album.title")
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Photo
|
||||||
|
fields = ["description", "album_title"]
|
||||||
|
|
||||||
|
photo_serializer = PhotoSerializer(data={'description': 'test', 'album_title': "some-title"})
|
||||||
|
self.assertTrue(photo_serializer.is_valid())
|
||||||
|
|
||||||
|
|
||||||
class RegexValidationTest(TestCase):
|
class RegexValidationTest(TestCase):
|
||||||
def test_create_failed(self):
|
def test_create_failed(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user