November 2015
Beginner to intermediate
840 pages
26h 30m
English
Before we make any changes to our code, it’s worth noting that we have already made a few optimizations to our website. The least obvious of the bunch is the order of condition checks in templates.
The Django Template Language (DTL) is rife with clever optimizations. One of the most powerful is condition short-circuiting. In Example 26.2, for instance, consider the condition in startup_detail.html.
Example 26.2: Project Code
organizer/templates/organizer/startup_detail.html in eb0dc1e1d1
114 {% if perms.blog.view_future_post and startup.blog_ . posts.all %}
The order of conditions in the DTL matter. In the preceding code, Django first checks our privileges, which are ...
Read now
Unlock full access