Skip to content

Commit 62f78df

Browse files
committed
Copy validators lists on instantiation.
1 parent 75e81b8 commit 62f78df

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

rest_framework/serializers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,9 @@ def get_validators(self):
327327
Returns a list of validator callables.
328328
"""
329329
# Used by the lazily-evaluated `validators` property.
330-
return getattr(getattr(self, 'Meta', None), 'validators', [])
330+
meta = getattr(self, 'Meta', None)
331+
validators = getattr(meta, 'validators', None)
332+
return validators[:] if validators else []
331333

332334
def get_initial(self):
333335
if hasattr(self, 'initial_data'):
@@ -1213,7 +1215,7 @@ def get_validators(self):
12131215
# If the validators have been declared explicitly then use that.
12141216
validators = getattr(getattr(self, 'Meta', None), 'validators', None)
12151217
if validators is not None:
1216-
return validators
1218+
return validators[:]
12171219

12181220
# Otherwise use the default set of validators.
12191221
return (

0 commit comments

Comments
 (0)