mirror of
				https://github.com/encode/django-rest-framework.git
				synced 2025-11-04 18:08:03 +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.
 | 
			
		||||
        """
 | 
			
		||||
        # 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 (
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user