O'Reilly logo

Django Unleashed by Andrew Pinkham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.6.2 Database Interaction via Managers

Django attaches an object called a manager to every model class. The manager helps interaction with the database in complicated ways: it is a key part of Django’s ORM (which is hinted at by the db in the path below) and is the most common way Django developers will interact with data in the database. Effectively, it is one of the most powerful tools inherited through models.Model and one with which we will be very familiar by the end of the book.

By default, Django automatically generates a manager for each model and assigns it to the objects attribute. As shown in Example 3.45, we can use the Python type() built-in to see what the object is.

Example 3.45: Python Interpreter Code

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required