Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/docs/ref/models/class.txt
blob: 0183a82093b2b3d53ad9973c67684172a26785e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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>`.