Skip to content

Commit e399140

Browse files
Minor tweaks
1 parent 555930e commit e399140

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

rest_framework/serializers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,9 @@ def get_initial(self):
393393
return ReturnList(serializer=self)
394394

395395
def get_value(self, dictionary):
396+
"""
397+
Given the input dictionary, return the field value.
398+
"""
396399
# We override the default field access in order to support
397400
# lists in HTML forms.
398401
if html.is_html_input(dictionary):
@@ -442,6 +445,9 @@ def to_representation(self, data):
442445
)
443446

444447
def save(self, **kwargs):
448+
"""
449+
Save and return a list of object instances.
450+
"""
445451
assert self.instance is None, (
446452
"Serializers do not support multiple update by default, only "
447453
"multiple create. For updates it is unclear how to deal with "

rest_framework/utils/field_mapping.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,11 @@ def get_relation_kwargs(field_name, relation_info):
219219
kwargs['required'] = False
220220
if model_field.null:
221221
kwargs['allow_null'] = True
222+
if model_field.validators:
223+
kwargs['validators'] = model_field.validators
222224
if getattr(model_field, 'unique', False):
223225
validator = UniqueValidator(queryset=model_field.model._default_manager)
224-
kwargs['validators'] = [validator]
226+
kwargs['validators'] = kwargs.get('validators', []) + [validator]
225227

226228
return kwargs
227229

0 commit comments

Comments
 (0)