mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 03:23:59 +03:00
Copy validators lists on instantiation.
This commit is contained in:
parent
75e81b8254
commit
62f78dfbf1
|
@ -327,7 +327,9 @@ class Serializer(BaseSerializer):
|
||||||
Returns a list of validator callables.
|
Returns a list of validator callables.
|
||||||
"""
|
"""
|
||||||
# Used by the lazily-evaluated `validators` property.
|
# 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):
|
def get_initial(self):
|
||||||
if hasattr(self, 'initial_data'):
|
if hasattr(self, 'initial_data'):
|
||||||
|
@ -1213,7 +1215,7 @@ class ModelSerializer(Serializer):
|
||||||
# If the validators have been declared explicitly then use that.
|
# If the validators have been declared explicitly then use that.
|
||||||
validators = getattr(getattr(self, 'Meta', None), 'validators', None)
|
validators = getattr(getattr(self, 'Meta', None), 'validators', None)
|
||||||
if validators is not None:
|
if validators is not None:
|
||||||
return validators
|
return validators[:]
|
||||||
|
|
||||||
# Otherwise use the default set of validators.
|
# Otherwise use the default set of validators.
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue
Block a user