aboutsummaryrefslogtreecommitdiffstats
path: root/docs/api-guide/fields.md
diff options
context:
space:
mode:
authorJamie Matthews2012-11-19 17:22:17 +0000
committerJamie Matthews2012-11-19 17:22:17 +0000
commitde5b071d677074ab3b6b33a843c4b05ba2052a6b (patch)
treeb19923214d4befe95603c827d828cb2c4f5c68b8 /docs/api-guide/fields.md
parentd1472740bc5f08871343d1a63e409e34d05504cb (diff)
downloaddjango-rest-framework-de5b071d677074ab3b6b33a843c4b05ba2052a6b.tar.bz2
Add SerializerMethodField
Diffstat (limited to 'docs/api-guide/fields.md')
-rw-r--r--docs/api-guide/fields.md6
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