This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Avoid magic numbers. | |
| seconds_per_hour = 3600 | |
| minutes_per_hour = 60 | |
| # Duration is a total number of seconds, but get be derived from timedelta.total_seconds(). | |
| t = timedelta(hours=2, minutes=15) | |
| total_seconds = t.total_seconds() | |
| # Store output in a list. | |
| a = list() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {# Assuming a page object with one or more instances of a content block: #} | |
| {% for block in page.blocks %} | |
| {# Start a new row every third block. #} | |
| {% cycle '<div class="row">' "" "" %} | |
| <div class="col-md-4"> | |
| {{ block }} | |
| </div> | |
| {# End every third row. #} | |
| {% cycle "" "" '</div>' %} | |
| {% endfor %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env python | |
| import os | |
| import sys | |
| # Define the path to the project. | |
| PROJECT_PATH = os.path.abspath(os.path.join("example", "source")) | |
| # Let Django know where things are. | |
| os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings") |
OlderNewer