summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2007-06-01 13:39:08 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2007-06-01 13:39:08 +0000
commitea07351799ea71084c1279ad9f5dab1f81362c4b (patch)
treec48eb688ac3ec68be456b9a0544fc797da07d6fb /docs
parent8728e0f35398e05bba9956b5b85f7cc3fbf33143 (diff)
Fixed #3466 -- Fixed problem with specifyin a 'fields' argument to a JSON serializer. Also added documenation for the 'fields' argument.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5409 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/serialization.txt24
1 files changed, 24 insertions, 0 deletions
diff --git a/docs/serialization.txt b/docs/serialization.txt
index 3216cb061e..6f307baf52 100644
--- a/docs/serialization.txt
+++ b/docs/serialization.txt
@@ -44,6 +44,25 @@ This is useful if you want to serialize data directly to a file-like object
.. _HTTPResponse: ../request_response/#httpresponse-objects
+Subset of fields
+~~~~~~~~~~~~~~~~
+
+If you only want a subset of fields to be serialized, you can
+specify a `fields` argument to the serializer::
+
+ from django.core import serializers
+ data = serializers.serialize('xml', SomeModel.objects.all(), fields=('name','size'))
+
+In this example, only the `name` and `size` attributes of each model will
+be serialized.
+
+.. note::
+
+ Depending on your model, you may find that it is not possible to deserialize
+ a model that only serializes a subset of it's fields. If a serialized object
+ doesn't specify all the fields that are required by a model, the deserializer
+ will not be able to save deserialized instances.
+
Deserializing data
------------------
@@ -92,10 +111,15 @@ Django "ships" with a few included serializers:
``python`` Translates to and from "simple" Python objects (lists, dicts,
strings, etc.). Not really all that useful on its own, but
used as a base for other serializers.
+
+ ``yaml`` Serializes to YAML (Yet Another Markup Lanuage). This
+ serializer will only be made available if PyYAML_ is installed.
+
========== ==============================================================
.. _json: http://json.org/
.. _simplejson: http://undefined.org/python/#simplejson
+.. _PyYAML: http://www.pyyaml.org/
Notes for specific serialization formats
----------------------------------------