diff options
| author | Chris Beaven <smileychris@gmail.com> | 2010-12-21 04:40:08 +0000 |
|---|---|---|
| committer | Chris Beaven <smileychris@gmail.com> | 2010-12-21 04:40:08 +0000 |
| commit | b60d5df07266dd4cd4f63afa6986ffb2932facc2 (patch) | |
| tree | a08f75ea3485e70b5b18bde8ea7d44414b78a0bc /docs | |
| parent | c2657d892396c51448432637a855eb9ecac5363c (diff) | |
Fixes #13252 -- Use the natural key instead of the primary key when serializing
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14994 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/topics/serialization.txt | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/docs/topics/serialization.txt b/docs/topics/serialization.txt index c8acc8539e..358f869a07 100644 --- a/docs/topics/serialization.txt +++ b/docs/topics/serialization.txt @@ -307,6 +307,12 @@ into the primary key of an actual ``Person`` object. fields will be effectively unique, you can still use those fields as a natural key. +.. versionchanged:: 1.3 + +Deserialization of objects with no primary key will always check whether the +model's manager has a ``get_by_natural_key()`` method and if so, use it to +populate the deserialized object's primary key. + Serialization of natural keys ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -353,6 +359,23 @@ use the `--natural` command line flag to generate natural keys. natural keys during serialization, but *not* be able to load those key values, just don't define the ``get_by_natural_key()`` method. +.. versionchanged:: 1.3 + +When ``use_natural_keys=True`` is specified, the primary key is no longer +provided in the serialized data of this object since it can be calculated +during deserialization:: + + ... + { + "model": "store.person", + "fields": { + "first_name": "Douglas", + "last_name": "Adams", + "birth_date": "1952-03-11", + } + } + ... + Dependencies during serialization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
