Minor tweaks

This commit is contained in:
Tom Christie 2014-11-07 10:51:08 +00:00
parent 555930ee81
commit e399140031
2 changed files with 9 additions and 1 deletions

View File

@ -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):
) )
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 "

View File

@ -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