aboutsummaryrefslogtreecommitdiffstats
path: root/docs/api-guide
diff options
context:
space:
mode:
authorTom Christie2015-01-23 16:27:23 +0000
committerTom Christie2015-01-23 16:27:23 +0000
commit35f6a8246299d31ecce4f791f9527bf34cebe6e2 (patch)
treee68af328d0e280d188e5de10b2feb1cf522fd961 /docs/api-guide
parent889a07f5563a0f970639a0958c0dcbc26e82919f (diff)
downloaddjango-rest-framework-35f6a8246299d31ecce4f791f9527bf34cebe6e2.tar.bz2
Added DictField and support for HStoreField.
Diffstat (limited to 'docs/api-guide')
-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