db.models.Model.objects

Model.objects

Each non-abstract Model class must have a 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 Manager instance. If you add your own Manager instance attribute, the default one does not appear. Consider the following example:

1
2
3
4
5
from django.db import models
 
class Person(models.Model):
    # Add manager with another name
    people = models.Manager()

For more details on model managers see Managers and Retrieving objects.

doc_Django
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.