For the purposes of this illustration, we create a new Django app called maintenance located in /path/to/repo/www/chapter_10/maintenance. The logic in views.py, shown here, is extremely simple. The main work is done by the user domain service. The resulting iteration is then rendered in the totals.html template and injected into the main layout.html template.
As usual, the module starts with a set of import statements:
from django.template.loader import render_to_string
from django.http import HttpResponse
from config.config import Config
from db.mongodb.connection import Connection
from biglittle.domain.user import UserService
We then define a method, totals(), which runs the report and sends the results to the view template:
def totals(request) :
config = Config()
userSvc = UserService(config, 'User')
totals = userSvc.fetchTotalsByLender()
params = { 'totals' : totals }
main = render_to_string...