May 2018
Beginner to intermediate
282 pages
7h 58m
English
Every Django model has a default manager called objects. Invoking objects.all(), will return all the entries for that model in the database. Usually, we are interested in only a subset of all entries.
We apply various filters to find out the set of entries we need. The criterion to select them is often our core business logic. For example, we can find the posts accessible to the public by the following code:
public = Posts.objects.filter(privacy="public")
This criterion might change in the future. For example, we might want to also check whether the post was marked for editing. This change might look as follows:
public = Posts.objects.filter(privacy=POST_PRIVACY.Public,
draft=False)
However, this change needs to be made ...
Read now
Unlock full access