August 2016
Beginner to intermediate
717 pages
15h 24m
English
This section contains design patterns that deal with accessing model properties or performing queries on them.
Problem: Models have attributes that are implemented as methods. However, these attributes should not be persisted to the database.
Solution: Use the property decorator on such methods.
Model fields store per-instance attributes, such as first name, last name, birthday, and so on. They are also stored in the database. However, we also need to access some derived attributes, such as full name or age.
They can be easily calculated from the database fields, hence need not be stored separately. In some cases, they can just be a conditional check such as eligibility for offers based on ...
Read now
Unlock full access