summaryrefslogtreecommitdiff
path: root/docs/userguide/serialization.rst
diff options
context:
space:
mode:
Diffstat (limited to 'docs/userguide/serialization.rst')
-rw-r--r--docs/userguide/serialization.rst17
1 files changed, 17 insertions, 0 deletions
diff --git a/docs/userguide/serialization.rst b/docs/userguide/serialization.rst
index 86eb04bb..f8523e69 100644
--- a/docs/userguide/serialization.rst
+++ b/docs/userguide/serialization.rst
@@ -54,6 +54,23 @@ Each option has its advantages and disadvantages.
you need cross-language support, the default setting of `JSON`
is probably your best choice.
+ If you need support for custom types, you can write serialize/deserialize
+ functions and register them as follows:
+
+ .. code-block:: python
+
+ from kombu.utils.json import register_type
+ from django.db.models import Model
+ from django.apps import apps
+
+ # Allow serialization of django models:
+ register_type(
+ Model,
+ "model",
+ lambda o: [o._meta.label, o.pk],
+ lambda o: apps.get_model(o[0]).objects.get(pk=o[1]),
+ )
+
`pickle` -- If you have no desire to support any language other than
Python, then using the `pickle` encoding will gain you
the support of all built-in Python data types (except class instances),