Book Image

Mastering Django: Core

By : Nigel George
Book Image

Mastering Django: Core

By: Nigel George

Overview of this book

Mastering Django: Core is a completely revised and updated version of the original Django Book, written by Adrian Holovaty and Jacob Kaplan-Moss - the creators of Django. The main goal of this book is to make you a Django expert. By reading this book, you’ll learn the skills needed to develop powerful websites quickly, with code that is clean and easy to maintain. This book is also a programmer’s manual that provides complete coverage of the current Long Term Support (LTS) version of Django. For developers creating applications for commercial and business critical deployments, Mastering Django: Core provides a complete, up-to-date resource for Django 1.8LTS with a stable code-base, security fixes and support out to 2018.
Table of Contents (33 chapters)
Mastering Django: Core
Credits
About the Author
www.PacktPub.com
Preface
Free Chapter
1
Introduction to Django and Getting Started

Model metadata options


Table A.3 is a complete list of model meta options you can give your model in its internal class Meta. For more detail on each meta option as well as examples, see the Django documentation at https://docs.djangoproject.com/en/1.8/ref/models/options/.

Option

Notes

abstract

If abstract = True, this model will be an abstract base class.

app_label

If a model is defined outside of an application in INSTALLED_APPS, it must declare which app it belongs to.

db_table

The name of the database table to use for the model.

db_tablespace

The name of the database tablespace to use for this model. The default is the project's DEFAULT_TABLESPACE setting, if set. If the backend doesn't support tablespaces, this option is ignored.

default_related_name

The name that will be used by default for the relation from a related object back to this one. The default is <model_name>_set.

get_latest_by

The name of an orderable field in the model, typically a DateField, DateTimeField, or IntegerField.

managed

Defaults to True, meaning Django will create the appropriate database tables in migrate or as part of migrations and remove them as part of a flush management command.

order_with_respect_to

Marks this object as orderable with respect to the given field.

ordering

The default ordering for the object, for use when obtaining lists of objects.

permissions

Extra permissions to enter into the permissions table when creating this object.

default_permissions

Defaults to ('add', 'change', 'delete').

proxy

If proxy = True, a model which subclasses another model will be treated as a proxy model.

select_on_save

Determines if Django will use the pre-1.6 django.db.models.Model.save() algorithm.

unique_together

Sets of field names that, taken together, must be unique.

index_together

Sets of field names that, taken together, are indexed.

verbose_name

A human-readable name for the object, singular.

verbose_name_plural

The plural name for the object.

Table A.3: Model metadata options