aboutsummaryrefslogtreecommitdiffstats
path: root/docs/api-guide/fields.md
diff options
context:
space:
mode:
authorXavier Ordoquy2014-02-18 11:42:35 +0100
committerXavier Ordoquy2014-02-18 11:42:35 +0100
commitb2f0f4fcf49d457aefc21960f62fcb8f2cf6770d (patch)
tree9adabfaa8c2a73e9b1304f8d699a3f70f284634a /docs/api-guide/fields.md
parent5ae94547bc08ade94c3f1df2223c0b8261cae59f (diff)
parent822eb39599b248c68573c3095639a831ab6df99a (diff)
downloaddjango-rest-framework-b2f0f4fcf49d457aefc21960f62fcb8f2cf6770d.tar.bz2
Merge remote-tracking branch 'reference/master' into feature/django_1_7
Diffstat (limited to 'docs/api-guide/fields.md')
-rw-r--r--docs/api-guide/fields.md5
1 files changed, 3 insertions, 2 deletions
diff --git a/docs/api-guide/fields.md b/docs/api-guide/fields.md
index c136509b..93f992e6 100644
--- a/docs/api-guide/fields.md
+++ b/docs/api-guide/fields.md
@@ -104,6 +104,7 @@ A serializer definition that looked like this:
expired = serializers.Field(source='has_expired')
class Meta:
+ model = Account
fields = ('url', 'owner', 'name', 'expired')
Would produce output similar to:
@@ -125,7 +126,7 @@ A field that supports both read and write operations. By itself `WritableField`
## ModelField
-A generic field that can be tied to any arbitrary model field. The `ModelField` class delegates the task of serialization/deserialization to it's associated model field. This field can be used to create serializer fields for custom model fields, without having to create a new custom serializer field.
+A generic field that can be tied to any arbitrary model field. The `ModelField` class delegates the task of serialization/deserialization to its associated model field. This field can be used to create serializer fields for custom model fields, without having to create a new custom serializer field.
The `ModelField` class is generally intended for internal use, but can be used by your API if needed. In order to properly instantiate a `ModelField`, it must be passed a field that is attached to an instantiated model. For example: `ModelField(model_field=MyModel()._meta.get_field('custom_field'))`
@@ -307,7 +308,7 @@ Django's regular [FILE_UPLOAD_HANDLERS] are used for handling uploaded files.
If you want to create a custom field, you'll probably want to override either one or both of the `.to_native()` and `.from_native()` methods. These two methods are used to convert between the initial datatype, and a primitive, serializable datatype. Primitive datatypes may be any of a number, string, date/time/datetime or None. They may also be any list or dictionary like object that only contains other primitive objects.
-The `.to_native()` method is called to convert the initial datatype into a primitive, serializable datatype. The `from_native()` method is called to restore a primitive datatype into it's initial representation.
+The `.to_native()` method is called to convert the initial datatype into a primitive, serializable datatype. The `from_native()` method is called to restore a primitive datatype into its initial representation.
## Examples