summaryrefslogtreecommitdiff
path: root/docs/db-api.txt
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-03-18 10:21:50 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-03-18 10:21:50 +0000
commit670be13986b74f252d479ee2b7f74da8655273f6 (patch)
tree61a2a676086e0b5a2261961879cc1d09e9678949 /docs/db-api.txt
parent8b52e8e40e100f02f09138947fee706c00c3ccbc (diff)
queryset-refactor: Undo [7220] and allow ordering on multi-valued field.
Some people will shoot themselves in the foot with this. That's bad luck. The reason we need it is because some data semantics cannot be expressed in Django's ORM and that shouldn't prevent ordering on that data. For example, filtering suburbs by a geographic region and then ordering on the suburb names. The names might not be unique outside that region, but unique inside it. Django cannot know that (you can't tell the model about it), so we trust the caller. git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7285 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/db-api.txt')
-rw-r--r--docs/db-api.txt13
1 files changed, 7 insertions, 6 deletions
diff --git a/docs/db-api.txt b/docs/db-api.txt
index af5ba8ce49..e15b0b2176 100644
--- a/docs/db-api.txt
+++ b/docs/db-api.txt
@@ -510,12 +510,13 @@ primary key if there is no ``Meta.ordering`` specified. For example::
...since the ``Blog`` model has no default ordering specified.
-You can only order by model fields that have a single value attached to them
-for each instance of the model. For example, non-relations, ``ForeignKey`` and
-``OneToOneField`` fields. Explicitly, you can't order by a ``ManyToManyField``
-or a reverse ``ForeignKey`` relation. There's no naturally correct ordering
-for many-valued fields and a lot of the alternatives are not psosible to
-express in SQL very efficiently.
+It is permissible to specify a multi-valued field to order the results by (for
+example, a ``ManyToMany`` field). Normally this won't be a sensible thing to
+do and it's really an advanced usage feature. However, if you know that your
+queryset's filtering or available data implies that there will only be one
+ordering piece of data for each of the main items you are selecting, the
+ordering may well be exactly what you want to do. Use ordering on multi-valued
+fields with care and make sure the results are what you expect.
**New in Django development version:** If you don't want any ordering to be
applied to a query, not even the default ordering, call ``order_by()`` with no