diff options
| author | Jamie Matthews | 2012-11-19 17:22:17 +0000 |
|---|---|---|
| committer | Jamie Matthews | 2012-11-19 17:22:17 +0000 |
| commit | de5b071d677074ab3b6b33a843c4b05ba2052a6b (patch) | |
| tree | b19923214d4befe95603c827d828cb2c4f5c68b8 /docs/api-guide/fields.md | |
| parent | d1472740bc5f08871343d1a63e409e34d05504cb (diff) | |
| download | django-rest-framework-de5b071d677074ab3b6b33a843c4b05ba2052a6b.tar.bz2 | |
Add SerializerMethodField
Diffstat (limited to 'docs/api-guide/fields.md')
| -rw-r--r-- | docs/api-guide/fields.md | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/docs/api-guide/fields.md b/docs/api-guide/fields.md index d1c31ecc..b19c324a 100644 --- a/docs/api-guide/fields.md +++ b/docs/api-guide/fields.md @@ -324,5 +324,11 @@ This field is always read-only. * `pk_url_kwarg` - The named url parameter for the pk field lookup. Default is `pk`. * `slug_url_kwarg` - The named url parameter for the slug field lookup. Default is to use the same value as given for `slug_field`. +# Other Fields + +## SerializerMethodField + +This is a read-only field gets its value by calling a method on the serializer class it's attached to. It can be used to add any sort of data to the serialized representation of your object. The field's constructor accepts a single argument, which is the name of the method on the serializer to be called. The method should accept a single argument (in addition to `self`), which is the object being serialized. It should return whatever you want to be included in the serialized representation of the object. + [cite]: http://www.python.org/dev/peps/pep-0020/ [FILE_UPLOAD_HANDLERS]: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FILE_UPLOAD_HANDLERS |
