November 2015
Beginner to intermediate
840 pages
26h 30m
English
It is possible to pass options to model fields. These field options can constrain behavior or provide defaults to our data, allowing us to write less code later. As model fields are (instances of) Python classes, we are simply passing parameters to the instantiation of field classes.
One of the most powerful options available is the ability to tell Django and the database that certain values are unique. This is particularly useful for slugs, which we know must be unique (SlugField instances do not default to being unique because of the many options available, as we shall see in Chapter 10: Revisiting Migrations). In the case of our Tag model, in /organizer/models.py, we set both the
Read now
Unlock full access