Django middleware and view decorator to detect phones and small-screen devices
Python
Pull request Compare This branch is 43 commits ahead, 1 commit behind vkuzma:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Experiments
minidetector
.gitignore
.travis.yml
AUTHORS
LICENSE
MANIFEST.in
README.md
__init__.py
requirements.txt
setup.py

README.md

Build Status

This application is a simple middleware and associated decorator that will add a ".mobile" attribute to your request objects, which, if True, means the requester is coming to you from a mobile phone (cellphone), PDA, or other device that should be considered small screened, or have an underpowered browser, such as games consoles.

This mostly works using a list of search strings, though there are a couple of other tricks, like detecting the presence of Opera Mini. The strings are in an easily-parseable text file, and thus can be used for other similar projects.

It also includes a pretty extensive list of user agents to test against.

It also adds a dictionary to the request object, to figure out which device as well as if it's a Facebook app.

To run the tests

$ python -m unittest minidetector.tests