Fixed #22019 -- Added Model.objects reference documentation.
This commit is contained in:
parent
a2dd618e3b
commit
5b185ecc68
|
@ -61,7 +61,8 @@ manipulating the data of your Web application. Learn more about it below:
|
||||||
* **Models:**
|
* **Models:**
|
||||||
:doc:`Model syntax <topics/db/models>` |
|
:doc:`Model syntax <topics/db/models>` |
|
||||||
:doc:`Field types <ref/models/fields>` |
|
: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:**
|
* **QuerySets:**
|
||||||
:doc:`Executing queries <topics/db/queries>` |
|
:doc:`Executing queries <topics/db/queries>` |
|
||||||
|
|
|
@ -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>`.
|
|
@ -9,6 +9,7 @@ Model API reference. For introductory material, see :doc:`/topics/db/models`.
|
||||||
|
|
||||||
fields
|
fields
|
||||||
relations
|
relations
|
||||||
|
class
|
||||||
options
|
options
|
||||||
instances
|
instances
|
||||||
querysets
|
querysets
|
||||||
|
|
|
@ -681,8 +681,9 @@ Model attributes
|
||||||
:class:`~django.db.models.Manager`. It's the interface through which
|
:class:`~django.db.models.Manager`. It's the interface through which
|
||||||
database query operations are provided to Django models and is used to
|
database query operations are provided to Django models and is used to
|
||||||
:ref:`retrieve the instances <retrieving-objects>` from the database. If no
|
:ref:`retrieve the instances <retrieving-objects>` from the database. If no
|
||||||
custom ``Manager`` is defined, the default name is ``objects``. Managers
|
custom ``Manager`` is defined, the default name is
|
||||||
are only accessible via model classes, not the model instances.
|
:attr:`~django.db.models.Model.objects`. Managers are only accessible via
|
||||||
|
model classes, not the model instances.
|
||||||
|
|
||||||
.. _model-methods:
|
.. _model-methods:
|
||||||
|
|
||||||
|
|
|
@ -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
|
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`. Each model has at least one
|
||||||
:class:`~django.db.models.Manager`, and it's called ``objects`` by
|
:class:`~django.db.models.Manager`, and it's called
|
||||||
default. Access it directly via the model class, like so::
|
:attr:`~django.db.models.Model.objects` by default. Access it directly via the
|
||||||
|
model class, like so::
|
||||||
|
|
||||||
>>> Blog.objects
|
>>> Blog.objects
|
||||||
<django.db.models.manager.Manager object at ...>
|
<django.db.models.manager.Manager object at ...>
|
||||||
|
|
Loading…
Reference in New Issue