mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-27 08:29:59 +03:00
Default SerializerMethodField's help_text to the docstring of the method.
This commit is contained in:
parent
c05998f5dd
commit
7a3d96d48a
|
@ -1878,6 +1878,11 @@ class SerializerMethodField(Field):
|
|||
# The method name defaults to `get_{field_name}`.
|
||||
if self.method_name is None:
|
||||
self.method_name = 'get_{field_name}'.format(field_name=field_name)
|
||||
# If help_text isn't specified, try to get the method's docstring.
|
||||
if self.help_text is None:
|
||||
method = getattr(parent, self.method_name, None)
|
||||
if method is not None:
|
||||
self.help_text = method.__doc__
|
||||
|
||||
super().bind(field_name, parent)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user