-
Book Overview & Buying
-
Table Of Contents
Web Development with Django Cookbook - Second Edition
By :
The HttpRequest object contains useful information about the current user, language, server variables, cookies, session, and so on. As a matter of fact, HttpRequest is provided in the views and middlewares, and then you can pass it or its attribute values to forms, model methods, model managers, templates, and so on. To make life easier, you can use the ThreadLocalMiddleware middleware that stores the current HttpRequest object in the globally-accessed Python thread. Therefore, you can access it from model methods, forms, signal handlers, and any other place that didn't have direct access to the HttpRequest object previously. In this recipe, we will define this middleware.
Create the utils app and put it under INSTALLED_APPS in the settings.
Execute the following two steps:
middleware.py file in the utils app with the following content:# utils/middleware.py
# -*- coding: UTF-8 -*-
from threading import local
_thread_locals...
Change the font size
Change margin width
Change background colour