aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/serializers.py
diff options
context:
space:
mode:
authorTom Christie2013-05-24 23:44:23 +0100
committerTom Christie2013-05-24 23:44:23 +0100
commitfcaee6e580efc62658a5b155525c55ef427c5778 (patch)
treef46d5966d96e52c6e77df73c0f7c19200a82f1c7 /rest_framework/serializers.py
parent760e8642bd04b5e03409601a8d378799c36eac1b (diff)
downloaddjango-rest-framework-fcaee6e580efc62658a5b155525c55ef427c5778.tar.bz2
Clean up OPTIONS implementation
Diffstat (limited to 'rest_framework/serializers.py')
-rw-r--r--rest_framework/serializers.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py
index 17da8c25..5be07fb7 100644
--- a/rest_framework/serializers.py
+++ b/rest_framework/serializers.py
@@ -521,12 +521,16 @@ class BaseSerializer(WritableField):
return self.object
- @property
- def humanized(self):
- humanized_fields = SortedDict(
- [(name, field.humanized)
- for name, field in self.fields.iteritems()])
- return humanized_fields
+ def metadata(self):
+ """
+ Return a dictionary of metadata about the fields on the serializer.
+ Useful for things like responding to OPTIONS requests, or generating
+ API schemas for auto-documentation.
+ """
+ return SortedDict(
+ [(field_name, field.metadata())
+ for field_name, field in six.iteritems(self.fields)]
+ )
class Serializer(six.with_metaclass(SerializerMetaclass, BaseSerializer)):