Snippet List
This middleware adds a "is_mobile" (boolean) to the request object if the user's browser is a mobile browser (iPhone, Nokia, etc).
**Example of use inside a view:** `request.is_mobile`
**Example of use inside a template:** *You must activate the template processor "django.core.context_processors.request" in your settings. (see TEMPLATE_CONTEXT_PROCESSORS at djangoproject.com)* `{{ request.is_mobile }}`
- middleware
- detect
- browser
- detection
- mobile
Sometimes you need to know if a visitor is a bot or if the browser supports certain features or if it is a mobile device.
The easiest way to do so would be to lookup the user agent in a capabilities database.
Fortunately there is already such a database called browscap.ini which is widely known among PHP users.
I found the file accidently on my harddrive because it is also used by Mono: /etc/mono/browscap.ini
Read http://browsers.garykeith.com/index.asp for more information.
Before importing the module you need to call the script from commandline to retrieve the browscap.ini file. Look at the test function to see how to use it.
You can also create a file called "bupdate.ini" which can contain fixes for wrong or incomplete entries, e.g:
[Konqueror]
javaapplets=True
- ie
- browscap
- browser
- detection
- firefox
- opera
- mozilla
- safari
2 snippets posted so far.