Copy validators lists on instantiation.

This commit is contained in:
Tom Christie 2014-12-19 15:50:29 +00:00
parent 75e81b8254
commit 62f78dfbf1

View File

@ -327,7 +327,9 @@ class Serializer(BaseSerializer):
Returns a list of validator callables.
"""
# Used by the lazily-evaluated `validators` property.
return getattr(getattr(self, 'Meta', None), 'validators', [])
meta = getattr(self, 'Meta', None)
validators = getattr(meta, 'validators', None)
return validators[:] if validators else []
def get_initial(self):
if hasattr(self, 'initial_data'):
@ -1213,7 +1215,7 @@ class ModelSerializer(Serializer):
# If the validators have been declared explicitly then use that.
validators = getattr(getattr(self, 'Meta', None), 'validators', None)
if validators is not None:
return validators
return validators[:]
# Otherwise use the default set of validators.
return (