mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 03:23:59 +03:00
Minor tweaks
This commit is contained in:
parent
555930ee81
commit
e399140031
|
@ -393,6 +393,9 @@ class ListSerializer(BaseSerializer):
|
|||
return ReturnList(serializer=self)
|
||||
|
||||
def get_value(self, dictionary):
|
||||
"""
|
||||
Given the input dictionary, return the field value.
|
||||
"""
|
||||
# We override the default field access in order to support
|
||||
# lists in HTML forms.
|
||||
if html.is_html_input(dictionary):
|
||||
|
@ -442,6 +445,9 @@ class ListSerializer(BaseSerializer):
|
|||
)
|
||||
|
||||
def save(self, **kwargs):
|
||||
"""
|
||||
Save and return a list of object instances.
|
||||
"""
|
||||
assert self.instance is None, (
|
||||
"Serializers do not support multiple update by default, only "
|
||||
"multiple create. For updates it is unclear how to deal with "
|
||||
|
|
|
@ -219,9 +219,11 @@ def get_relation_kwargs(field_name, relation_info):
|
|||
kwargs['required'] = False
|
||||
if model_field.null:
|
||||
kwargs['allow_null'] = True
|
||||
if model_field.validators:
|
||||
kwargs['validators'] = model_field.validators
|
||||
if getattr(model_field, 'unique', False):
|
||||
validator = UniqueValidator(queryset=model_field.model._default_manager)
|
||||
kwargs['validators'] = [validator]
|
||||
kwargs['validators'] = kwargs.get('validators', []) + [validator]
|
||||
|
||||
return kwargs
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user