Appendix C. Database API Reference

Django's database API is the other half of the model API discussed in Appendix B. Once you've defined a model, you'll use this API any time you need to access the database. You've seen examples of this API in use throughout the book; this appendix explains all the various options in detail.

Like the model APIs discussed in Appendix B, though, these APIs are considered very stable, the Django developers consistently add new shortcuts and conveniences. It's a good idea to always check the latest documentation online, available at

Throughout this reference, we'll refer to the following models, which might form a simple Weblog application:

from django.db import ...

Get The Definitive Guide to Django: Web Development Done Right now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.