diff --git a/docs/index.txt b/docs/index.txt index 621f530920..e0529c4503 100644 --- a/docs/index.txt +++ b/docs/index.txt @@ -61,7 +61,8 @@ manipulating the data of your Web application. Learn more about it below: * **Models:** :doc:`Model syntax ` | :doc:`Field types ` | - :doc:`Meta options ` + :doc:`Meta options ` | + :doc:`Model class ` * **QuerySets:** :doc:`Executing queries ` | diff --git a/docs/ref/models/class.txt b/docs/ref/models/class.txt new file mode 100644 index 0000000000..0183a82093 --- /dev/null +++ b/docs/ref/models/class.txt @@ -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 `. + +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 ` + and :ref:`Retrieving objects `. diff --git a/docs/ref/models/index.txt b/docs/ref/models/index.txt index 4716c03f95..3462420a00 100644 --- a/docs/ref/models/index.txt +++ b/docs/ref/models/index.txt @@ -9,6 +9,7 @@ Model API reference. For introductory material, see :doc:`/topics/db/models`. fields relations + class options instances querysets diff --git a/docs/topics/db/models.txt b/docs/topics/db/models.txt index 1571226e67..d883abf8ab 100644 --- a/docs/topics/db/models.txt +++ b/docs/topics/db/models.txt @@ -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 ` 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: diff --git a/docs/topics/db/queries.txt b/docs/topics/db/queries.txt index 9d0663434d..d8132cb573 100644 --- a/docs/topics/db/queries.txt +++ b/docs/topics/db/queries.txt @@ -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