Code

Ticket #12107: 12107.model_meta_serialize.1.diff

File 12107.model_meta_serialize.1.diff, 1.9 KB (added by emulbreh, 4 years ago)

with docs

Line 
1Index: django/db/models/options.py
2===================================================================
3--- django/db/models/options.py (revision 11680)
4+++ django/db/models/options.py (working copy)
5@@ -21,7 +21,7 @@
6 DEFAULT_NAMES = ('verbose_name', 'db_table', 'ordering',
7                  'unique_together', 'permissions', 'get_latest_by',
8                  'order_with_respect_to', 'app_label', 'db_tablespace',
9-                 'abstract', 'managed', 'proxy')
10+                 'abstract', 'managed', 'proxy', 'serialize')
11 
12 class Options(object):
13     def __init__(self, meta, app_label=None):
14@@ -45,6 +45,7 @@
15         self.managed = True
16         self.proxy = False
17         self.proxy_for_model = None
18+        self.serialize = True
19         self.parents = SortedDict()
20         self.duplicate_targets = {}
21 
22Index: django/core/management/commands/dumpdata.py
23===================================================================
24--- django/core/management/commands/dumpdata.py (revision 11680)
25+++ django/core/management/commands/dumpdata.py (working copy)
26@@ -73,7 +73,7 @@
27                 model_list = get_models(app)
28 
29             for model in model_list:
30-                if not model._meta.proxy:
31+                if not model._meta.proxy and model._meta.serialize:
32                     objects.extend(model._default_manager.all())
33 
34         try:
35Index: docs/ref/models/options.txt
36===================================================================
37--- docs/ref/models/options.txt (revision 11680)
38+++ docs/ref/models/options.txt (working copy)
39@@ -200,6 +200,15 @@
40 If set to ``True``, a model which subclasses another model will be treated as
41 a :ref:`proxy model <proxy-models>`.
42 
43+``serialize``
44+-------------
45+
46+.. attribute:: Options.serialize
47+
48+.. versionadded:: 1.2
49+
50+If set to ``False``, the model will not be serialized by ``django-admin.py dumpdata``. Defaults to ``True``.
51+
52 ``unique_together``
53 -------------------
54