Model class reference

This document covers features of the Model class. For more information about models, see the complete list of Model reference guides.

Attributes

objects

Model.objects

每个非抽象的Model类必须添加一个Manager实例。 Django确保在你的模型类中至少有一个指定的默认Manager 如果你没有添加自己的Manager,Django会添加一个属性objects,其中包含默认的Manager实例。 如果添加自己的Manager实例属性,则不会显示默认的属性。 Consider the following example:

from django.db import models

class Person(models.Model):
    # Add manager with another name
    people = models.Manager()

有关模型管理器的更多详细信息,请参阅管理器检索对象