Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.2.X] Fixed #14842 - Indent the model Meta options. Thanks adamv.

Backport of r15110 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15111 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit cd2cf8724326db425ce762925415ff4c90153830 1 parent 6c51b80
Tim Graham authored

Showing 1 changed file with 118 additions and 117 deletions. Show diff stats Hide diff stats

  1. 235  docs/ref/models/options.txt
235  docs/ref/models/options.txt
@@ -3,8 +3,8 @@ Model ``Meta`` options
3 3
 ======================
4 4
 
5 5
 This document explains all the possible :ref:`metadata options
6  
-<meta-options>` that you can give your model in its internal ``class
7  
-Meta``.
  6
+<meta-options>` that you can give your model in its internal
  7
+``class Meta``.
8 8
 
9 9
 Available ``Meta`` options
10 10
 ==========================
@@ -16,27 +16,28 @@ Available ``Meta`` options
16 16
 
17 17
 .. attribute:: Options.abstract
18 18
 
19  
-If ``True``, this model will be an :ref:`abstract base class <abstract-base-classes>`.
  19
+    If ``abstract = True``, this model will be an
  20
+    :ref:`abstract base class <abstract-base-classes>`.
20 21
 
21 22
 ``app_label``
22 23
 -------------
23 24
 
24 25
 .. attribute:: Options.app_label
25 26
 
26  
-If a model exists outside of the standard :file:`models.py` (for instance, if
27  
-the app's models are in submodules of ``myapp.models``), the model must define
28  
-which app it is part of::
  27
+    If a model exists outside of the standard :file:`models.py` (for instance,
  28
+    if the app's models are in submodules of ``myapp.models``), the model must
  29
+    define which app it is part of::
29 30
 
30  
-    app_label = 'myapp'
  31
+        app_label = 'myapp'
31 32
 
32 33
 ``db_table``
33 34
 ------------
34 35
 
35 36
 .. attribute:: Options.db_table
36 37
 
37  
-The name of the database table to use for the model::
  38
+    The name of the database table to use for the model::
38 39
 
39  
-    db_table = 'music_album'
  40
+        db_table = 'music_album'
40 41
 
41 42
 .. _table-names:
42 43
 
@@ -46,8 +47,8 @@ Table names
46 47
 To save you time, Django automatically derives the name of the database table
47 48
 from the name of your model class and the app that contains it. A model's
48 49
 database table name is constructed by joining the model's "app label" -- the
49  
-name you used in ``manage.py startapp`` -- to the model's class name, with an
50  
-underscore between them.
  50
+name you used in :djadmin:`manage.py startapp <startapp>` -- to the model's
  51
+class name, with an underscore between them.
51 52
 
52 53
 For example, if you have an app ``bookstore`` (as created by
53 54
 ``manage.py startapp bookstore``), a model defined as ``class Book`` will have
@@ -65,201 +66,201 @@ Django quotes column and table names behind the scenes.
65 66
 
66 67
 .. attribute:: Options.db_tablespace
67 68
 
68  
-The name of the database tablespace to use for the model. If the backend doesn't
69  
-support tablespaces, this option is ignored.
  69
+    The name of the database tablespace to use for the model. If the backend
  70
+    doesn't support tablespaces, this option is ignored.
70 71
 
71 72
 ``get_latest_by``
72 73
 -----------------
73 74
 
74 75
 .. attribute:: Options.get_latest_by
75 76
 
76  
-The name of a :class:`DateField` or :class:`DateTimeField` in the model. This
77  
-specifies the default field to use in your model :class:`Manager`'s
78  
-:class:`~QuerySet.latest` method.
  77
+    The name of a :class:`DateField` or :class:`DateTimeField` in the model.
  78
+    This specifies the default field to use in your model :class:`Manager`'s
  79
+    :class:`~QuerySet.latest` method.
79 80
 
80  
-Example::
  81
+    Example::
81 82
 
82  
-    get_latest_by = "order_date"
  83
+        get_latest_by = "order_date"
83 84
 
84  
-See the docs for :meth:`~django.db.models.QuerySet.latest` for more.
  85
+    See the docs for :meth:`~django.db.models.QuerySet.latest` for more.
85 86
 
86 87
 ``managed``
87  
------------------------
  88
+-----------
88 89
 
89 90
 .. attribute:: Options.managed
90 91
 
91  
-.. versionadded:: 1.1
  92
+    .. versionadded:: 1.1
92 93
 
93  
-Defaults to ``True``, meaning Django will create the appropriate database
94  
-tables in :djadmin:`syncdb` and remove them as part of a :djadmin:`reset`
95  
-management command. That is, Django *manages* the database tables' lifecycles.
  94
+    Defaults to ``True``, meaning Django will create the appropriate database
  95
+    tables in :djadmin:`syncdb` and remove them as part of a :djadmin:`reset`
  96
+    management command. That is, Django *manages* the database tables' lifecycles.
96 97
 
97  
-If ``False``, no database table creation or deletion operations will be
98  
-performed for this model. This is useful if the model represents an existing
99  
-table or a database view that has been created by some other means. This is
100  
-the *only* difference when ``managed`` is ``False``. All other aspects of
101  
-model handling are exactly the same as normal. This includes
  98
+    If ``False``, no database table creation or deletion operations will be
  99
+    performed for this model. This is useful if the model represents an existing
  100
+    table or a database view that has been created by some other means. This is
  101
+    the *only* difference when ``managed=False``. All other aspects of
  102
+    model handling are exactly the same as normal. This includes
102 103
 
103  
-    1. Adding an automatic primary key field to the model if you don't declare
104  
-       it.  To avoid confusion for later code readers, it's recommended to
105  
-       specify all the columns from the database table you are modeling when
106  
-       using unmanaged models.
  104
+        1. Adding an automatic primary key field to the model if you don't declare
  105
+           it.  To avoid confusion for later code readers, it's recommended to
  106
+           specify all the columns from the database table you are modeling when
  107
+           using unmanaged models.
107 108
 
108  
-    2. If a model with ``managed=False`` contains a
109  
-       :class:`~django.db.models.ManyToManyField` that points to another
110  
-       unmanaged model, then the intermediate table for the many-to-many join
111  
-       will also not be created. However, the intermediary table between one
112  
-       managed and one unmanaged model *will* be created.
  109
+        2. If a model with ``managed=False`` contains a
  110
+           :class:`~django.db.models.ManyToManyField` that points to another
  111
+           unmanaged model, then the intermediate table for the many-to-many join
  112
+           will also not be created. However, the intermediary table between one
  113
+           managed and one unmanaged model *will* be created.
113 114
 
114  
-       If you need to change this default behavior, create the intermediary
115  
-       table as an explicit model (with ``managed`` set as needed) and use the
116  
-       :attr:`ManyToManyField.through` attribute to make the relation use your
117  
-       custom model.
  115
+           If you need to change this default behavior, create the intermediary
  116
+           table as an explicit model (with ``managed`` set as needed) and use the
  117
+           :attr:`ManyToManyField.through` attribute to make the relation use your
  118
+           custom model.
118 119
 
119  
-For tests involving models with ``managed=False``, it's up to you to ensure
120  
-the correct tables are created as part of the test setup.
  120
+    For tests involving models with ``managed=False``, it's up to you to ensure
  121
+    the correct tables are created as part of the test setup.
121 122
 
122  
-If you're interested in changing the Python-level behavior of a model class,
123  
-you *could* use ``managed=False`` and create a copy of an existing model.
124  
-However, there's a better approach for that situation: :ref:`proxy-models`.
  123
+    If you're interested in changing the Python-level behavior of a model class,
  124
+    you *could* use ``managed=False`` and create a copy of an existing model.
  125
+    However, there's a better approach for that situation: :ref:`proxy-models`.
125 126
 
126 127
 ``order_with_respect_to``
127 128
 -------------------------
128 129
 
129 130
 .. attribute:: Options.order_with_respect_to
130 131
 
131  
-Marks this object as "orderable" with respect to the given field. This is almost
132  
-always used with related objects to allow them to be ordered with respect to a
133  
-parent object. For example, if an ``Answer`` relates to a ``Question`` object,
134  
-and a question has more than one answer, and the order of answers matters, you'd
135  
-do this::
  132
+    Marks this object as "orderable" with respect to the given field. This is almost
  133
+    always used with related objects to allow them to be ordered with respect to a
  134
+    parent object. For example, if an ``Answer`` relates to a ``Question`` object,
  135
+    and a question has more than one answer, and the order of answers matters, you'd
  136
+    do this::
136 137
 
137  
-    class Answer(models.Model):
138  
-        question = models.ForeignKey(Question)
139  
-        # ...
  138
+        class Answer(models.Model):
  139
+            question = models.ForeignKey(Question)
  140
+            # ...
140 141
 
141  
-        class Meta:
142  
-            order_with_respect_to = 'question'
  142
+            class Meta:
  143
+                order_with_respect_to = 'question'
143 144
 
144  
-When ``order_with_respect_to`` is set, two additional methods are provided to
145  
-retrieve and to set the order of the related objects: ``get_RELATED_order()``
146  
-and ``set_RELATED_order()``, where ``RELATED`` is the lowercased model name. For
147  
-example, assuming that a ``Question`` object has multiple related ``Answer``
148  
-objects, the list returned contains the primary keys of the related ``Answer``
149  
-objects::
  145
+    When ``order_with_respect_to`` is set, two additional methods are provided to
  146
+    retrieve and to set the order of the related objects: ``get_RELATED_order()``
  147
+    and ``set_RELATED_order()``, where ``RELATED`` is the lowercased model name. For
  148
+    example, assuming that a ``Question`` object has multiple related ``Answer``
  149
+    objects, the list returned contains the primary keys of the related ``Answer``
  150
+    objects::
150 151
 
151  
-    >>> question = Question.objects.get(id=1)
152  
-    >>> question.get_answer_order()
153  
-    [1, 2, 3]
  152
+        >>> question = Question.objects.get(id=1)
  153
+        >>> question.get_answer_order()
  154
+        [1, 2, 3]
154 155
 
155  
-The order of a ``Question`` object's related ``Answer`` objects can be set by
156  
-passing in a list of ``Answer`` primary keys::
  156
+    The order of a ``Question`` object's related ``Answer`` objects can be set by
  157
+    passing in a list of ``Answer`` primary keys::
157 158
 
158  
-    >>> question.set_answer_order([3, 1, 2])
  159
+        >>> question.set_answer_order([3, 1, 2])
159 160
 
160  
-The related objects also get two methods, ``get_next_in_order()`` and
161  
-``get_previous_in_order()``, which can be used to access those objects in their
162  
-proper order. Assuming the ``Answer`` objects are ordered by ``id``::
  161
+    The related objects also get two methods, ``get_next_in_order()`` and
  162
+    ``get_previous_in_order()``, which can be used to access those objects in their
  163
+    proper order. Assuming the ``Answer`` objects are ordered by ``id``::
163 164
 
164  
-    >>> answer = Answer.objects.get(id=2)
165  
-    >>> answer.get_next_in_order()
166  
-    <Answer: 3>
167  
-    >>> answer.get_previous_in_order()
168  
-    <Answer: 1>
  165
+        >>> answer = Answer.objects.get(id=2)
  166
+        >>> answer.get_next_in_order()
  167
+        <Answer: 3>
  168
+        >>> answer.get_previous_in_order()
  169
+        <Answer: 1>
169 170
 
170 171
 ``ordering``
171 172
 ------------
172 173
 
173 174
 .. attribute:: Options.ordering
174 175
 
175  
-The default ordering for the object, for use when obtaining lists of objects::
  176
+    The default ordering for the object, for use when obtaining lists of objects::
176 177
 
177  
-    ordering = ['-order_date']
  178
+        ordering = ['-order_date']
178 179
 
179  
-This is a tuple or list of strings. Each string is a field name with an optional
180  
-"-" prefix, which indicates descending order. Fields without a leading "-" will
181  
-be ordered ascending. Use the string "?" to order randomly.
  180
+    This is a tuple or list of strings. Each string is a field name with an optional
  181
+    "-" prefix, which indicates descending order. Fields without a leading "-" will
  182
+    be ordered ascending. Use the string "?" to order randomly.
182 183
 
183  
-.. note::
  184
+    .. note::
184 185
 
185  
-    Regardless of how many fields are in :attr:`~Options.ordering`, the admin
186  
-    site uses only the first field.
  186
+        Regardless of how many fields are in :attr:`~Options.ordering`, the admin
  187
+        site uses only the first field.
187 188
 
188  
-For example, to order by a ``pub_date`` field ascending, use this::
  189
+    For example, to order by a ``pub_date`` field ascending, use this::
189 190
 
190  
-    ordering = ['pub_date']
  191
+        ordering = ['pub_date']
191 192
 
192  
-To order by ``pub_date`` descending, use this::
  193
+    To order by ``pub_date`` descending, use this::
193 194
 
194  
-    ordering = ['-pub_date']
  195
+        ordering = ['-pub_date']
195 196
 
196  
-To order by ``pub_date`` descending, then by ``author`` ascending, use this::
  197
+    To order by ``pub_date`` descending, then by ``author`` ascending, use this::
197 198
 
198  
-    ordering = ['-pub_date', 'author']
  199
+        ordering = ['-pub_date', 'author']
199 200
 
200 201
 ``permissions``
201 202
 ---------------
202 203
 
203 204
 .. attribute:: Options.permissions
204 205
 
205  
-Extra permissions to enter into the permissions table when creating this object.
206  
-Add, delete and change permissions are automatically created for each object
207  
-that has ``admin`` set. This example specifies an extra permission,
208  
-``can_deliver_pizzas``::
  206
+    Extra permissions to enter into the permissions table when creating this object.
  207
+    Add, delete and change permissions are automatically created for each object
  208
+    that has ``admin`` set. This example specifies an extra permission,
  209
+    ``can_deliver_pizzas``::
209 210
 
210  
-    permissions = (("can_deliver_pizzas", "Can deliver pizzas"),)
  211
+        permissions = (("can_deliver_pizzas", "Can deliver pizzas"),)
211 212
 
212  
-This is a list or tuple of 2-tuples in the format ``(permission_code,
213  
-human_readable_permission_name)``.
  213
+    This is a list or tuple of 2-tuples in the format ``(permission_code,
  214
+    human_readable_permission_name)``.
214 215
 
215 216
 ``proxy``
216 217
 ---------
217 218
 
218 219
 .. attribute:: Options.proxy
219 220
 
220  
-.. versionadded:: 1.1
  221
+    .. versionadded:: 1.1
221 222
 
222  
-If set to ``True``, a model which subclasses another model will be treated as
223  
-a :ref:`proxy model <proxy-models>`.
  223
+    If ``proxy = True``, a model which subclasses another model will be treated as
  224
+    a :ref:`proxy model <proxy-models>`.
224 225
 
225 226
 ``unique_together``
226 227
 -------------------
227 228
 
228 229
 .. attribute:: Options.unique_together
229 230
 
230  
-Sets of field names that, taken together, must be unique::
  231
+    Sets of field names that, taken together, must be unique::
231 232
 
232  
-    unique_together = (("driver", "restaurant"),)
  233
+        unique_together = (("driver", "restaurant"),)
233 234
 
234  
-This is a list of lists of fields that must be unique when considered together.
235  
-It's used in the Django admin and is enforced at the database level (i.e., the
236  
-appropriate ``UNIQUE`` statements are included in the ``CREATE TABLE``
237  
-statement).
  235
+    This is a list of lists of fields that must be unique when considered together.
  236
+    It's used in the Django admin and is enforced at the database level (i.e., the
  237
+    appropriate ``UNIQUE`` statements are included in the ``CREATE TABLE``
  238
+    statement).
238 239
 
239  
-For convenience, unique_together can be a single list when dealing with a single
240  
-set of fields::
  240
+    For convenience, unique_together can be a single list when dealing with a single
  241
+    set of fields::
241 242
 
242  
-    unique_together = ("driver", "restaurant")
  243
+        unique_together = ("driver", "restaurant")
243 244
 
244 245
 ``verbose_name``
245 246
 ----------------
246 247
 
247 248
 .. attribute:: Options.verbose_name
248 249
 
249  
-A human-readable name for the object, singular::
  250
+    A human-readable name for the object, singular::
250 251
 
251  
-    verbose_name = "pizza"
  252
+        verbose_name = "pizza"
252 253
 
253  
-If this isn't given, Django will use a munged version of the class name:
254  
-``CamelCase`` becomes ``camel case``.
  254
+    If this isn't given, Django will use a munged version of the class name:
  255
+    ``CamelCase`` becomes ``camel case``.
255 256
 
256 257
 ``verbose_name_plural``
257 258
 -----------------------
258 259
 
259 260
 .. attribute:: Options.verbose_name_plural
260 261
 
261  
-The plural name for the object::
  262
+    The plural name for the object::
262 263
 
263  
-    verbose_name_plural = "stories"
  264
+        verbose_name_plural = "stories"
264 265
 
265  
-If this isn't given, Django will use :attr:`~Options.verbose_name` + ``"s"``.
  266
+    If this isn't given, Django will use :attr:`~Options.verbose_name` + ``"s"``.

0 notes on commit cd2cf87

Please sign in to comment.
Something went wrong with that request. Please try again.