File: class.txt

package info (click to toggle)
python-django 1%3A1.11.29-1~deb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 47,428 kB
  • sloc: python: 220,776; javascript: 13,523; makefile: 209; xml: 201; sh: 64
file content (35 lines) | stat: -rw-r--r-- 1,201 bytes parent folder | download | duplicates (4)
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>`.