diff options
| author | Stephan Groß | 2013-05-28 17:13:12 +0200 | 
|---|---|---|
| committer | Stephan Groß | 2013-05-28 17:13:12 +0200 | 
| commit | 7a570e16e97a42d58855b5c06ea7b4d2cc0745e6 (patch) | |
| tree | 09c25da3773f9680ad35127bc9838e6701926a2f /docs/api-guide/serializers.md | |
| parent | d7bf02e09ea85778c0a3fad572ad33d637c0602f (diff) | |
| download | django-rest-framework-7a570e16e97a42d58855b5c06ea7b4d2cc0745e6.tar.bz2 | |
Fix md formatting and typos
Diffstat (limited to 'docs/api-guide/serializers.md')
| -rw-r--r-- | docs/api-guide/serializers.md | 14 | 
1 files changed, 7 insertions, 7 deletions
diff --git a/docs/api-guide/serializers.md b/docs/api-guide/serializers.md index 053a5eaf..71f0abb7 100644 --- a/docs/api-guide/serializers.md +++ b/docs/api-guide/serializers.md @@ -3,7 +3,7 @@  # Serializers  > Expanding the usefulness of the serializers is something that we would -like to address. However, it's not a trivial problem, and it +like to address.  However, it's not a trivial problem, and it  will take some serious design work.  >  > — Russell Keith-Magee, [Django users group][cite] @@ -104,11 +104,11 @@ When deserializing a list of items, errors will be returned as a list of diction  #### Field-level validation -You can specify custom field-level validation by adding `.validate_<fieldname>` methods to your `Serializer` subclass. These are analogous to `.clean_<fieldname>` methods on Django forms, but accept slightly different arguments. +You can specify custom field-level validation by adding `.validate_<fieldname>` methods to your `Serializer` subclass.  These are analogous to `.clean_<fieldname>` methods on Django forms, but accept slightly different arguments.  They take a dictionary of deserialized attributes as a first argument, and the field name in that dictionary as a second argument (which will be either the name of the field or the value of the `source` argument to the field, if one was provided). -Your `validate_<fieldname>` methods should either just return the `attrs` dictionary or raise a `ValidationError`. For example: +Your `validate_<fieldname>` methods should either just return the `attrs` dictionary or raise a `ValidationError`.  For example:      from rest_framework import serializers @@ -127,7 +127,7 @@ Your `validate_<fieldname>` methods should either just return the `attrs` dictio  #### Object-level validation -To do any other validation that requires access to multiple fields, add a method called `.validate()` to your `Serializer` subclass. This method takes a single argument, which is the `attrs` dictionary. It should raise a `ValidationError` if necessary, or just return `attrs`.  For example: +To do any other validation that requires access to multiple fields, add a method called `.validate()` to your `Serializer` subclass.  This method takes a single argument, which is the `attrs` dictionary.  It should raise a `ValidationError` if necessary, or just return `attrs`.  For example:      from rest_framework import serializers @@ -285,7 +285,7 @@ To map the incoming data items to their corresponding object instances, the `.ge  There are some cases where you need to provide extra context to the serializer in addition to the object being serialized.  One common case is if you're using a serializer that includes hyperlinked relations, which requires the serializer to have access to the current request so that it can properly generate fully qualified URLs. -You can provide arbitrary additional context by passing a `context` argument when instantiating the serializer. For example: +You can provide arbitrary additional context by passing a `context` argument when instantiating the serializer.  For example:      serializer = AccountSerializer(account, context={'request': request})      serializer.data @@ -333,7 +333,7 @@ The `depth` option should be set to an integer value that indicates the depth of  ## Specifying which fields should be read-only  -You may wish to specify multiple fields as read-only. Instead of adding each field explicitly with the `read_only=True` attribute, you may use the `read_only_fields` Meta option, like so: +You may wish to specify multiple fields as read-only.  Instead of adding each field explicitly with the `read_only=True` attribute, you may use the `read_only_fields` Meta option, like so:      class AccountSerializer(serializers.ModelSerializer):          class Meta: @@ -425,7 +425,7 @@ Doing so should be considered advanced usage, and will only be needed if you hav  The `field_mapping` attribute is a dictionary that maps model classes to serializer classes.  Overriding the attribute will let you set a different set of default serializer classes.  -For more advanced customization than simply changing the default serializer class you can override various `get_<field_type>_field` methods.  Doing so will allow you to customize the arguments that each serializer field is initialized with. Each of these methods may either return a field or serializer instance, or `None`. +For more advanced customization than simply changing the default serializer class you can override various `get_<field_type>_field` methods.  Doing so will allow you to customize the arguments that each serializer field is initialized with.  Each of these methods may either return a field or serializer instance, or `None`.  ### get_pk_field  | 
