aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorTom Christie2015-01-23 16:33:37 +0000
committerTom Christie2015-01-23 16:33:37 +0000
commit8f6d7f4a5a34a144700d943cb8fcf496d0d3734a (patch)
tree10d78980e5511e1aa41175b8a11fc2b97e26f429 /docs
parentb07d931261c2e9f722fb2de63ab17f088142b6f1 (diff)
parent35f6a8246299d31ecce4f791f9527bf34cebe6e2 (diff)
downloaddjango-rest-framework-8f6d7f4a5a34a144700d943cb8fcf496d0d3734a.tar.bz2
Merge pull request #2451 from tomchristie/dict-field
Added DictField and support for HStoreField.
Diffstat (limited to 'docs')
-rw-r--r--docs/api-guide/fields.md19
1 files changed, 18 insertions, 1 deletions
diff --git a/docs/api-guide/fields.md b/docs/api-guide/fields.md
index 64ec902b..1c78a42b 100644
--- a/docs/api-guide/fields.md
+++ b/docs/api-guide/fields.md
@@ -380,7 +380,7 @@ A field class that validates a list of objects.
**Signature**: `ListField(child)`
-- `child` - A field instance that should be used for validating the objects in the list.
+- `child` - A field instance that should be used for validating the objects in the list. If this argument is not provided then objects in the list will not be validated.
For example, to validate a list of integers you might use something like the following:
@@ -395,6 +395,23 @@ The `ListField` class also supports a declarative style that allows you to write
We can now reuse our custom `StringListField` class throughout our application, without having to provide a `child` argument to it.
+## DictField
+
+A field class that validates a dictionary of objects. The keys in `DictField` are always assumed to be string values.
+
+**Signature**: `DictField(child)`
+
+- `child` - A field instance that should be used for validating the values in the dictionary. If this argument is not provided then values in the mapping will not be validated.
+
+For example, to create a field that validates a mapping of strings to strings, you would write something like this:
+
+ document = DictField(child=CharField())
+
+You can also use the declarative style, as with `ListField`. For example:
+
+ class DocumentField(DictField):
+ child = CharField()
+
---
# Miscellaneous fields