This document covers features of the Model
class.
For more information about models, see the complete list of Model
reference guides.
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()
Jan 17, 2018