Appendix B. Model Definition Reference

Chapter 5 explains the basics of defining models, and we use them throughout the rest of the book. There is, however, a huge range of model options available not covered elsewhere. This appendix explains each possible model definition option.

Note that although these APIs are considered very stable, the Django developers consistently add new shortcuts and conveniences to the model definition. It's a good idea to always check the latest documentation online at http://www.djangoproject.com/documentation/0.96/model-api/.

Fields

The most important part of a modeland the only required part of a modelis the list of database fields it defines.

Field Name Restrictions

Django places only two restrictions on model field ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.