summaryrefslogtreecommitdiff
path: root/docs/serialization.txt
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2007-06-07 21:49:06 +0000
committerAdrian Holovaty <adrian@holovaty.com>2007-06-07 21:49:06 +0000
commitd34639b09bf85dfb1b6f9a4b59f8ccbc3117230b (patch)
tree619db1e6fde32bbfb0c135bde382d1b1df395e9a /docs/serialization.txt
parent659d99b7afda730180e80ea4d68a7d505b21ba86 (diff)
newforms-admin: Merged to [5439]
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@5440 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/serialization.txt')
-rw-r--r--docs/serialization.txt23
1 files changed, 23 insertions, 0 deletions
diff --git a/docs/serialization.txt b/docs/serialization.txt
index 3216cb061e..01afa2708c 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 its 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,14 @@ 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 is only 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
----------------------------------------