Skip to content

Commit ff5f647

Browse files
authored
Fix example of requires_context attribute (#8952)
1 parent e2a4559 commit ff5f647

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

docs/api-guide/validators.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,14 @@ To write a class-based validator, use the `__call__` method. Class-based validat
295295

296296
In some advanced cases you might want a validator to be passed the serializer
297297
field it is being used with as additional context. You can do so by setting
298-
a `requires_context = True` attribute on the validator. The `__call__` method
298+
a `requires_context = True` attribute on the validator class. The `__call__` method
299299
will then be called with the `serializer_field`
300300
or `serializer` as an additional argument.
301301

302-
requires_context = True
302+
class MultipleOf:
303+
requires_context = True
303304

304-
def __call__(self, value, serializer_field):
305-
...
305+
def __call__(self, value, serializer_field):
306+
...
306307

307308
[cite]: https://docs.djangoproject.com/en/stable/ref/validators/

0 commit comments

Comments
 (0)