Commit e3991400 by Tom Christie

Minor tweaks

parent 555930ee
...@@ -393,6 +393,9 @@ class ListSerializer(BaseSerializer): ...@@ -393,6 +393,9 @@ class ListSerializer(BaseSerializer):
return ReturnList(serializer=self) return ReturnList(serializer=self)
def get_value(self, dictionary): def get_value(self, dictionary):
"""
Given the input dictionary, return the field value.
"""
# We override the default field access in order to support # We override the default field access in order to support
# lists in HTML forms. # lists in HTML forms.
if html.is_html_input(dictionary): if html.is_html_input(dictionary):
...@@ -442,6 +445,9 @@ class ListSerializer(BaseSerializer): ...@@ -442,6 +445,9 @@ class ListSerializer(BaseSerializer):
) )
def save(self, **kwargs): def save(self, **kwargs):
"""
Save and return a list of object instances.
"""
assert self.instance is None, ( assert self.instance is None, (
"Serializers do not support multiple update by default, only " "Serializers do not support multiple update by default, only "
"multiple create. For updates it is unclear how to deal with " "multiple create. For updates it is unclear how to deal with "
......
...@@ -219,9 +219,11 @@ def get_relation_kwargs(field_name, relation_info): ...@@ -219,9 +219,11 @@ def get_relation_kwargs(field_name, relation_info):
kwargs['required'] = False kwargs['required'] = False
if model_field.null: if model_field.null:
kwargs['allow_null'] = True kwargs['allow_null'] = True
if model_field.validators:
kwargs['validators'] = model_field.validators
if getattr(model_field, 'unique', False): if getattr(model_field, 'unique', False):
validator = UniqueValidator(queryset=model_field.model._default_manager) validator = UniqueValidator(queryset=model_field.model._default_manager)
kwargs['validators'] = [validator] kwargs['validators'] = kwargs.get('validators', []) + [validator]
return kwargs return kwargs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment