diff options
| author | Nick Sandford <nick@sandford.id.au> | 2013-01-12 16:37:19 +0800 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2013-01-20 06:39:35 +0200 |
| commit | fe54377dae1357a7f102d72614a13f0ef8b2dbdf (patch) | |
| tree | 73920c4aa4a6d5cfad76a844c35cf25b36583a81 /docs | |
| parent | 37718eb50b60f44462a64f735072e43a9d60b9a6 (diff) | |
Fixed #17813 -- Added a .earliest() method to QuerySet
Thanks a lot to everybody participating in developing this feature.
The patch was developed by multiple people, at least Trac aliases
tonnzor, jimmysong, Fandekasp and slurms.
Stylistic changes added by committer.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/models/options.txt | 3 | ||||
| -rw-r--r-- | docs/ref/models/querysets.txt | 21 | ||||
| -rw-r--r-- | docs/releases/1.6.txt | 3 |
3 files changed, 20 insertions, 7 deletions
diff --git a/docs/ref/models/options.txt b/docs/ref/models/options.txt index b349197a5b..21265d6313 100644 --- a/docs/ref/models/options.txt +++ b/docs/ref/models/options.txt @@ -86,7 +86,8 @@ Django quotes column and table names behind the scenes. The name of an orderable field in the model, typically a :class:`DateField`, :class:`DateTimeField`, or :class:`IntegerField`. This specifies the default field to use in your model :class:`Manager`'s - :meth:`~django.db.models.query.QuerySet.latest` method. + :meth:`~django.db.models.query.QuerySet.latest` and + :meth:`~django.db.models.query.QuerySet.earliest` methods. Example:: diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index 71049703c9..1f59ecb4f4 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -1477,14 +1477,23 @@ This example returns the latest ``Entry`` in the table, according to the If your model's :ref:`Meta <meta-options>` specifies :attr:`~django.db.models.Options.get_latest_by`, you can leave off the -``field_name`` argument to ``latest()``. Django will use the field specified -in :attr:`~django.db.models.Options.get_latest_by` by default. +``field_name`` argument to ``earliest()`` or ``latest()``. Django will use the +field specified in :attr:`~django.db.models.Options.get_latest_by` by default. -Like :meth:`get()`, ``latest()`` raises -:exc:`~django.core.exceptions.DoesNotExist` if there is no object with the given -parameters. +Like :meth:`get()`, ``earliest()`` and ``latest()`` raise +:exc:`~django.core.exceptions.DoesNotExist` if there is no object with the +given parameters. + +Note that ``earliest()`` and ``latest()`` exist purely for convenience and +readability. + +earliest +~~~~~~~~ + +.. method:: earliest(field_name=None) -Note ``latest()`` exists purely for convenience and readability. +Works otherwise like :meth:`~django.db.models.query.QuerySet.latest` except +the direction is changed. aggregate ~~~~~~~~~ diff --git a/docs/releases/1.6.txt b/docs/releases/1.6.txt index dcf6f2604a..89d7bb3c05 100644 --- a/docs/releases/1.6.txt +++ b/docs/releases/1.6.txt @@ -28,6 +28,9 @@ Minor features undefined if the given ``QuerySet`` isn't ordered and there are more than one ordered values to compare against. +* Added :meth:`~django.db.models.query.QuerySet.earliest` for symmetry with + :meth:`~django.db.models.query.QuerySet.latest`. + Backwards incompatible changes in 1.6 ===================================== |
