Commit 2eadc418 authored by Jannis Leidel's avatar Jannis Leidel
Browse files

Fixed doc references to `django.db.models.query.QuerySet` and converted some...

Fixed doc references to `django.db.models.query.QuerySet` and converted some tabs that were introduced in r16699 to spaces.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16915 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent ec5bfed5
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -321,9 +321,9 @@ will get you started for now.
A shortcut: get_object_or_404()
-------------------------------

It's a very common idiom to use :meth:`~django.db.models.QuerySet.get` and raise
:exc:`~django.http.Http404` if the object doesn't exist. Django provides a
shortcut. Here's the ``detail()`` view, rewritten::
It's a very common idiom to use :meth:`~django.db.models.query.QuerySet.get`
and raise :exc:`~django.http.Http404` if the object doesn't exist. Django
provides a shortcut. Here's the ``detail()`` view, rewritten::

    from django.shortcuts import render_to_response, get_object_or_404
    # ...
@@ -333,8 +333,8 @@ shortcut. Here's the ``detail()`` view, rewritten::

The :func:`~django.shortcuts.get_object_or_404` function takes a Django model
as its first argument and an arbitrary number of keyword arguments, which it
passes to the module's :meth:`~django.db.models.QuerySet.get` function. It
raises :exc:`~django.http.Http404` if the object doesn't exist.
passes to the module's :meth:`~django.db.models.query.QuerySet.get` function.
It raises :exc:`~django.http.Http404` if the object doesn't exist.

.. admonition:: Philosophy

@@ -349,9 +349,9 @@ raises :exc:`~django.http.Http404` if the object doesn't exist.

There's also a :func:`~django.shortcuts.get_list_or_404` function, which works
just as :func:`~django.shortcuts.get_object_or_404` -- except using
:meth:`~django.db.models.QuerySet.filter` instead of
:meth:`~django.db.models.QuerySet.get`. It raises :exc:`~django.http.Http404` if
the list is empty.
:meth:`~django.db.models.query.QuerySet.filter` instead of
:meth:`~django.db.models.query.QuerySet.get`. It raises
:exc:`~django.http.Http404` if the list is empty.

Write a 404 (page not found) view
=================================
+2 −2
Original line number Diff line number Diff line
@@ -388,7 +388,7 @@ MultipleObjectTemplateResponseMixin
    that operate upon a list of object instances. Requires that the view it is
    mixed with provides ``self.object_list``, the list of object instances that
    the view is operating on. ``self.object_list`` may be, but is not required
    to be, a :class:`~django.db.models.Queryset`.
    to be, a :class:`~django.db.models.query.QuerySet`.

    **Extends**

@@ -814,7 +814,7 @@ BaseDateListView
        Returns the list of dates of type ``date_type`` for which
        ``queryset`` contains entries. For example, ``get_date_list(qs,
        'year')`` will return the list of years for which ``qs`` has entries.
        See :meth:`~django.db.models.QuerySet.dates()` for the
        See :meth:`~django.db.models.query.QuerySet.dates()` for the
        ways that the ``date_type`` argument can be used.


+37 −36
Original line number Diff line number Diff line
@@ -23,8 +23,9 @@ models. For example, here's the user module from Django's built-in
.. warning::

    The "delete selected objects" action uses :meth:`QuerySet.delete()
    <django.db.models.QuerySet.delete>` for efficiency reasons, which has an
    important caveat: your model's ``delete()`` method will not be called.
    <django.db.models.query.QuerySet.delete>` for efficiency reasons, which
    has an important caveat: your model's ``delete()`` method will not be
    called.

    If you wish to override this behavior, simply write a custom action which
    accomplishes deletion in your preferred manner -- for example, by calling
@@ -74,8 +75,8 @@ three arguments:

    * The current :class:`ModelAdmin`
    * An :class:`~django.http.HttpRequest` representing the current request,
    * A :class:`~django.db.models.QuerySet` containing the set of objects
      selected by the user.
    * A :class:`~django.db.models.query.QuerySet` containing the set of
      objects selected by the user.

Our publish-these-articles function won't need the :class:`ModelAdmin` or the
request object, but we will use the queryset::
+8 −7
Original line number Diff line number Diff line
@@ -713,13 +713,14 @@ subclass::
.. attribute:: ModelAdmin.list_select_related

    Set ``list_select_related`` to tell Django to use
    :meth:`~django.db.models.QuerySet.select_related` in retrieving the list of
    objects on the admin change list page. This can save you a bunch of
    database queries.
    :meth:`~django.db.models.query.QuerySet.select_related` in retrieving
    the list of objects on the admin change list page. This can save you a
    bunch of database queries.

    The value should be either ``True`` or ``False``. Default is ``False``.

    Note that Django will use :meth:`~django.db.models.QuerySet.select_related`,
    Note that Django will use
    :meth:`~django.db.models.query.QuerySet.select_related`,
    regardless of this setting if one of the ``list_display`` fields is a
    ``ForeignKey``.

@@ -1182,9 +1183,9 @@ templates used by the :class:`ModelAdmin` views:
.. method:: ModelAdmin.queryset(self, request)

    The ``queryset`` method on a ``ModelAdmin`` returns a
    :class:`~django.db.models.QuerySet` of all model instances that can be
    edited by the admin site. One use case for overriding this method is
    to show objects owned by the logged-in user::
    :class:`~django.db.models.query.QuerySet` of all model instances that
    can be edited by the admin site. One use case for overriding this method
    is to show objects owned by the logged-in user::

        class MyModelAdmin(admin.ModelAdmin):
            def queryset(self, request):
+5 −4
Original line number Diff line number Diff line
@@ -116,7 +116,8 @@ model it represents, or to retrieve objects from that model:

    Takes a set of valid :ref:`lookup arguments <field-lookups-intro>` for the
    model the :class:`~django.contrib.contenttypes.models.ContentType`
    represents, and does :meth:`a get() lookup <django.db.models.QuerySet.get>`
    represents, and does
    :meth:`a get() lookup <django.db.models.query.QuerySet.get>`
    on that model, returning the corresponding object.

.. method:: ContentType.model_class()
@@ -416,9 +417,9 @@ might be tempted to try something like::

This will not work correctly, however. The generic relation adds extra filters
to the queryset to ensure the correct content type, but the
:meth:`~django.db.models.QuerySet.aggregate` method doesn't take them into
account. For now, if you need aggregates on generic relations, you'll need
to calculate them without using the aggregation API.
:meth:`~django.db.models.query.QuerySet.aggregate` method doesn't take them
into account. For now, if you need aggregates on generic relations, you'll
need to calculate them without using the aggregation API.

Generic relations in forms and admin
------------------------------------
Loading