Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.1.X] Fixed #12997 -- Added markup for methods in the queryset docs…

…. Thanks to Ramiro Morales for the patch.

Backport of r13162 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@13165 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 6df4ffd4f4e6ad6aafe7dc697645de16d14cd797 1 parent 3981355
Russell Keith-Magee authored May 09, 2010

Showing 1 changed file with 48 additions and 2 deletions. Show diff stats Hide diff stats

  1. 50  docs/ref/models/querysets.txt
50  docs/ref/models/querysets.txt
@@ -134,6 +134,8 @@ executed.
134 134
 ``filter(**kwargs)``
135 135
 ~~~~~~~~~~~~~~~~~~~~
136 136
 
  137
+.. method:: filter(**kwargs)
  138
+
137 139
 Returns a new ``QuerySet`` containing objects that match the given lookup
138 140
 parameters.
139 141
 
@@ -144,6 +146,8 @@ underlying SQL statement.
144 146
 ``exclude(**kwargs)``
145 147
 ~~~~~~~~~~~~~~~~~~~~~
146 148
 
  149
+.. method:: exclude(**kwargs)
  150
+
147 151
 Returns a new ``QuerySet`` containing objects that do *not* match the given
148 152
 lookup parameters.
149 153
 
@@ -177,6 +181,8 @@ Note the second example is more restrictive.
177 181
 ``annotate(*args, **kwargs)``
178 182
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
179 183
 
  184
+.. method:: annotate(*args, **kwargs)
  185
+
180 186
 .. versionadded:: 1.1
181 187
 
182 188
 Annotates each object in the ``QuerySet`` with the provided list of
@@ -219,6 +225,8 @@ Aggregation <topics-db-aggregation>`.
219 225
 ``order_by(*fields)``
220 226
 ~~~~~~~~~~~~~~~~~~~~~
221 227
 
  228
+.. method:: order_by(*fields)
  229
+
222 230
 By default, results returned by a ``QuerySet`` are ordered by the ordering
223 231
 tuple given by the ``ordering`` option in the model's ``Meta``. You can
224 232
 override this on a per-``QuerySet`` basis by using the ``order_by`` method.
@@ -293,6 +301,8 @@ You can tell if a query is ordered or not by checking the
293 301
 ``reverse()``
294 302
 ~~~~~~~~~~~~~
295 303
 
  304
+.. method:: reverse()
  305
+
296 306
 .. versionadded:: 1.0
297 307
 
298 308
 Use the ``reverse()`` method to reverse the order in which a queryset's
@@ -323,6 +333,8 @@ undefined afterward).
323 333
 ``distinct()``
324 334
 ~~~~~~~~~~~~~~
325 335
 
  336
+.. method:: distinct()
  337
+
326 338
 Returns a new ``QuerySet`` that uses ``SELECT DISTINCT`` in its SQL query. This
327 339
 eliminates duplicate rows from the query results.
328 340
 
@@ -357,6 +369,8 @@ query spans multiple tables, it's possible to get duplicate results when a
357 369
 ``values(*fields)``
358 370
 ~~~~~~~~~~~~~~~~~~~
359 371
 
  372
+.. method:: values(*fields)
  373
+
360 374
 Returns a ``ValuesQuerySet`` -- a ``QuerySet`` that returns dictionaries when
361 375
 used as an iterable, rather than model-instance objects.
362 376
 
@@ -445,6 +459,8 @@ individualism.
445 459
 ``values_list(*fields)``
446 460
 ~~~~~~~~~~~~~~~~~~~~~~~~
447 461
 
  462
+.. method:: values_list(*fields)
  463
+
448 464
 .. versionadded:: 1.0
449 465
 
450 466
 This is similar to ``values()`` except that instead of returning dictionaries,
@@ -473,6 +489,8 @@ fields in the model, in the order they were declared.
473 489
 ``dates(field, kind, order='ASC')``
474 490
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
475 491
 
  492
+.. method:: dates(field, kind, order='ASC')
  493
+
476 494
 Returns a ``DateQuerySet`` -- a ``QuerySet`` that evaluates to a list of
477 495
 ``datetime.datetime`` objects representing all available dates of a particular
478 496
 kind within the contents of the ``QuerySet``.
@@ -507,6 +525,8 @@ Examples::
507 525
 ``none()``
508 526
 ~~~~~~~~~~
509 527
 
  528
+.. method:: none()
  529
+
510 530
 .. versionadded:: 1.0
511 531
 
512 532
 Returns an ``EmptyQuerySet`` -- a ``QuerySet`` that always evaluates to
@@ -520,7 +540,9 @@ Examples::
520 540
     []
521 541
 
522 542
 ``all()``
523  
-~~~~~~~~~~
  543
+~~~~~~~~~
  544
+
  545
+.. method:: all()
524 546
 
525 547
 .. versionadded:: 1.0
526 548
 
@@ -535,6 +557,8 @@ definitely have a ``QuerySet`` to work with.
535 557
 ``select_related()``
536 558
 ~~~~~~~~~~~~~~~~~~~~
537 559
 
  560
+.. method:: select_related()
  561
+
538 562
 Returns a ``QuerySet`` that will automatically "follow" foreign-key
539 563
 relationships, selecting that additional related-object data when it executes
540 564
 its query. This is a performance booster which results in (sometimes much)
@@ -644,6 +668,8 @@ to ``select_related()`` are new in Django version 1.0.
644 668
 ``extra(select=None, where=None, params=None, tables=None, order_by=None, select_params=None)``
645 669
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
646 670
 
  671
+.. method:: extra(select=None, where=None, params=None, tables=None, order_by=None, select_params=None)
  672
+
647 673
 Sometimes, the Django query syntax by itself can't easily express a complex
648 674
 ``WHERE`` clause. For these edge cases, Django provides the ``extra()``
649 675
 ``QuerySet`` modifier -- a hook for injecting specific clauses into the SQL
@@ -806,6 +832,8 @@ of the arguments is required, but you should use at least one of them.
806 832
 ``defer(*fields)``
807 833
 ~~~~~~~~~~~~~~~~~~
808 834
 
  835
+.. method:: defer(*fields)
  836
+
809 837
 .. versionadded:: 1.1
810 838
 
811 839
 In some complex data-modeling situations, your models might contain a lot of
@@ -862,7 +890,9 @@ eventually).
862 890
     settled down and you understand where the hot-points are.
863 891
 
864 892
 ``only(*fields)``
865  
-~~~~~~~~~~~~~~~~~~
  893
+~~~~~~~~~~~~~~~~~
  894
+
  895
+.. method:: only(*fields)
866 896
 
867 897
 .. versionadded:: 1.1
868 898
 
@@ -912,6 +942,8 @@ they query the database each time they're called.
912 942
 ``get(**kwargs)``
913 943
 ~~~~~~~~~~~~~~~~~
914 944
 
  945
+.. method:: get(**kwargs)
  946
+
915 947
 Returns the object matching the given lookup parameters, which should be in
916 948
 the format described in `Field lookups`_.
917 949
 
@@ -939,6 +971,8 @@ The ``DoesNotExist`` exception inherits from
939 971
 ``create(**kwargs)``
940 972
 ~~~~~~~~~~~~~~~~~~~~
941 973
 
  974
+.. method:: create(**kwargs)
  975
+
942 976
 A convenience method for creating an object and saving it all in one step.  Thus::
943 977
 
944 978
     p = Person.objects.create(first_name="Bruce", last_name="Springsteen")
@@ -961,6 +995,8 @@ exception if you are using manual primary keys.
961 995
 ``get_or_create(**kwargs)``
962 996
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
963 997
 
  998
+.. method:: get_or_create(**kwargs)
  999
+
964 1000
 A convenience method for looking up an object with the given kwargs, creating
965 1001
 one if necessary.
966 1002
 
@@ -1029,6 +1065,8 @@ has a side effect on your data. For more, see `Safe methods`_ in the HTTP spec.
1029 1065
 ``count()``
1030 1066
 ~~~~~~~~~~~
1031 1067
 
  1068
+.. method:: count()
  1069
+
1032 1070
 Returns an integer representing the number of objects in the database matching
1033 1071
 the ``QuerySet``. ``count()`` never raises exceptions.
1034 1072
 
@@ -1052,6 +1090,8 @@ problems.
1052 1090
 ``in_bulk(id_list)``
1053 1091
 ~~~~~~~~~~~~~~~~~~~~
1054 1092
 
  1093
+.. method:: in_bulk(id_list)
  1094
+
1055 1095
 Takes a list of primary-key values and returns a dictionary mapping each
1056 1096
 primary-key value to an instance of the object with the given ID.
1057 1097
 
@@ -1071,6 +1111,8 @@ If you pass ``in_bulk()`` an empty list, you'll get an empty dictionary.
1071 1111
 ``iterator()``
1072 1112
 ~~~~~~~~~~~~~~
1073 1113
 
  1114
+.. method:: iterator()
  1115
+
1074 1116
 Evaluates the ``QuerySet`` (by performing the query) and returns an
1075 1117
 `iterator`_ over the results. A ``QuerySet`` typically caches its
1076 1118
 results internally so that repeated evaluations do not result in
@@ -1087,6 +1129,8 @@ been evaluated will force it to evaluate again, repeating the query.
1087 1129
 ``latest(field_name=None)``
1088 1130
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
1089 1131
 
  1132
+.. method:: latest(field_name=None)
  1133
+
1090 1134
 Returns the latest object in the table, by date, using the ``field_name``
1091 1135
 provided as the date field.
1092 1136
 
@@ -1107,6 +1151,8 @@ Note ``latest()`` exists purely for convenience and readability.
1107 1151
 ``aggregate(*args, **kwargs)``
1108 1152
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1109 1153
 
  1154
+.. method:: aggregate(*args, **kwargs)
  1155
+
1110 1156
 .. versionadded:: 1.1
1111 1157
 
1112 1158
 Returns a dictionary of aggregate values (averages, sums, etc) calculated

0 notes on commit 6df4ffd

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