mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54:16 +03:00
fields: allow help_text on SerializerMethodField
...by passing through any extra *args and **kwargs to the parent constructor. Previously one couldn't assign help_text to a SerializerMethodField during construction.
This commit is contained in:
parent
218b94e606
commit
04c820b8e5
|
@ -1027,9 +1027,9 @@ class SerializerMethodField(Field):
|
|||
A field that gets its value by calling a method on the serializer it's attached to.
|
||||
"""
|
||||
|
||||
def __init__(self, method_name):
|
||||
def __init__(self, method_name, *args, **kwargs):
|
||||
self.method_name = method_name
|
||||
super(SerializerMethodField, self).__init__()
|
||||
super(SerializerMethodField, self).__init__(*args, **kwargs)
|
||||
|
||||
def field_to_native(self, obj, field_name):
|
||||
value = getattr(self.parent, self.method_name)(obj)
|
||||
|
|
Loading…
Reference in New Issue
Block a user