Redirecting users to the mobile site (optional)
I saved this section for last because it's entirely optional and uses some advanced concepts. You can consider it as an extra credit exercise. None of the examples in the rest of the book rely on it, so you can safely skip it if you want.
Now that we have a second site set up for mobile users, we may want to automatically redirect our users to it if we can tell they are using a mobile device.
Note
Caution: This technique isn't foolproof and could cause difficulties for some of your users who want to be able to choose their mobile experience. We'll code a way with which they can get back to the main site, but consider this when deciding if you want to use the technique.
The HTTP_USER_AGENT
is the key piece of information we will use to determine how the user is accessing the site. It's a string containing the identity of the browser being used; consider it the "fingerprint" of the browser. In Django, the user agent string...