1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed #22019 -- Added Model.objects reference documentation.

This commit is contained in:
Aliaksandr Semianiuk 2014-05-16 23:40:00 +03:00 committed by Tim Graham
parent a2dd618e3b
commit 5b185ecc68
5 changed files with 44 additions and 5 deletions

View File

@ -61,7 +61,8 @@ manipulating the data of your Web application. Learn more about it below:
* **Models:**
:doc:`Model syntax <topics/db/models>` |
:doc:`Field types <ref/models/fields>` |
:doc:`Meta options <ref/models/options>`
:doc:`Meta options <ref/models/options>` |
:doc:`Model class <ref/models/class>`
* **QuerySets:**
:doc:`Executing queries <topics/db/queries>` |

35
docs/ref/models/class.txt Normal file
View File

@ -0,0 +1,35 @@
=====================
Model class reference
=====================
.. currentmodule:: django.db.models
This document covers features of the :class:`~django.db.models.Model` class.
For more information about models, see :doc:`the complete list of Model
reference guides </ref/models/index>`.
Attributes
==========
``objects``
-----------
.. attribute:: Model.objects
Each non-abstract :class:`~django.db.models.Model` class must have a
:class:`~django.db.models.Manager` instance added to it.
Django ensures that in your model class you have at least a
default ``Manager`` specified. If you don't add your own ``Manager``,
Django will add an attribute ``objects`` containing default
:class:`~django.db.models.Manager` instance. If you add your own
:class:`~django.db.models.Manager` instance attribute, the default one does
not appear. Consider the following example::
from django.db import models
class Person(models.Model):
# Add manager with another name
people = models.Manager()
For more details on model managers see :doc:`Managers </topics/db/managers>`
and :ref:`Retrieving objects <retrieving-objects>`.

View File

@ -9,6 +9,7 @@ Model API reference. For introductory material, see :doc:`/topics/db/models`.
fields
relations
class
options
instances
querysets

View File

@ -681,8 +681,9 @@ Model attributes
:class:`~django.db.models.Manager`. It's the interface through which
database query operations are provided to Django models and is used to
:ref:`retrieve the instances <retrieving-objects>` from the database. If no
custom ``Manager`` is defined, the default name is ``objects``. Managers
are only accessible via model classes, not the model instances.
custom ``Manager`` is defined, the default name is
:attr:`~django.db.models.Model.objects`. Managers are only accessible via
model classes, not the model instances.
.. _model-methods:

View File

@ -146,8 +146,9 @@ and a filter is a limiting clause such as ``WHERE`` or ``LIMIT``.
You get a :class:`~django.db.models.query.QuerySet` by using your model's
:class:`~django.db.models.Manager`. Each model has at least one
:class:`~django.db.models.Manager`, and it's called ``objects`` by
default. Access it directly via the model class, like so::
:class:`~django.db.models.Manager`, and it's called
:attr:`~django.db.models.Model.objects` by default. Access it directly via the
model class, like so::
>>> Blog.objects
<django.db.models.manager.Manager object at ...>