mirror of
				https://github.com/encode/django-rest-framework.git
				synced 2025-10-31 16:07:38 +03:00 
			
		
		
		
	Fix example of requires_context attribute (#8952)
				
					
				
			This commit is contained in:
		
							parent
							
								
									e2a4559c03
								
							
						
					
					
						commit
						ff5f647df0
					
				|  | @ -295,10 +295,11 @@ To write a class-based validator, use the `__call__` method. Class-based validat | |||
| 
 | ||||
| In some advanced cases you might want a validator to be passed the serializer | ||||
| field it is being used with as additional context. You can do so by setting | ||||
| a `requires_context = True` attribute on the validator. The `__call__` method | ||||
| a `requires_context = True` attribute on the validator class. The `__call__` method | ||||
| will then be called with the `serializer_field` | ||||
| or `serializer` as an additional argument. | ||||
| 
 | ||||
|     class MultipleOf: | ||||
|         requires_context = True | ||||
| 
 | ||||
|         def __call__(self, value, serializer_field): | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user