1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #13252 -- Added ability to serialize with natural primary keys.

Added ``--natural-foreign`` and ``--natural-primary`` options and
deprecated the ``--natural`` option to the ``dumpdata`` management
command.

Added ``use_natural_foreign_keys`` and ``use_natural_primary_keys``
arguments and deprecated the ``use_natural_keys`` argument to
``django.core.serializers.Serializer.serialize()``.

Thanks SmileyChris for the suggestion.
This commit is contained in:
Tai Lee
2012-08-01 11:49:01 +10:00
committed by Tim Graham
parent 945e033a69
commit e527c0b6d8
12 changed files with 211 additions and 50 deletions

View File

@@ -220,13 +220,34 @@ also mix application names and model names.
The :djadminopt:`--database` option can be used to specify the database
from which data will be dumped.
.. django-admin-option:: --natural-foreign
.. versionadded:: 1.7
When this option is specified, Django will use the ``natural_key()`` model
method to serialize any foreign key and many-to-many relationship to objects of
the type that defines the method. If you are dumping ``contrib.auth``
``Permission`` objects or ``contrib.contenttypes`` ``ContentType`` objects, you
should probably be using this flag. See the :ref:`natural keys
<topics-serialization-natural-keys>` documentation for more details on this
and the next option.
.. django-admin-option:: --natural-primary
.. versionadded:: 1.7
When this option is specified, Django will not provide the primary key in the
serialized data of this object since it can be calculated during
deserialization.
.. django-admin-option:: --natural
.. deprecated:: 1.7
Equivalent to the :djadminopt:`--natural-foreign` option; use that instead.
Use :ref:`natural keys <topics-serialization-natural-keys>` to represent
any foreign key and many-to-many relationship with a model that provides
a natural key definition. If you are dumping ``contrib.auth`` ``Permission``
objects or ``contrib.contenttypes`` ``ContentType`` objects, you should
probably be using this flag.
a natural key definition.
.. versionadded:: 1.6