File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -306,7 +306,7 @@ def get_validation_error_detail(exc):
306
306
# If errors may be a dict we use the standard {key: list of values}.
307
307
# Here we ensure that all the values are *lists* of errors.
308
308
return {
309
- key : value if isinstance (value , list ) else [value ]
309
+ key : value if isinstance (value , ( list , dict ) ) else [value ]
310
310
for key , value in exc .detail .items ()
311
311
}
312
312
elif isinstance (exc .detail , list ):
Original file line number Diff line number Diff line change @@ -49,6 +49,24 @@ class Meta:
49
49
fields = ('renamed' ,)
50
50
51
51
52
+ class TestNestedValidationError (TestCase ):
53
+ def test_nested_validation_error_detail (self ):
54
+ """
55
+ Ensure nested validation error detail is rendered correctly.
56
+ """
57
+ e = serializers .ValidationError ({
58
+ 'nested' : {
59
+ 'field' : ['error' ],
60
+ }
61
+ })
62
+
63
+ self .assertEqual (serializers .get_validation_error_detail (e ), {
64
+ 'nested' : {
65
+ 'field' : ['error' ],
66
+ }
67
+ })
68
+
69
+
52
70
class TestPreSaveValidationExclusionsSerializer (TestCase ):
53
71
def test_renamed_fields_are_model_validated (self ):
54
72
"""
You can’t perform that action at this time.
0 commit comments