Detect request's mobile user agents using the mobileesp lib.
Project description
settings.py
MIDDLEWARE_CLASSES = ( ... 'django_mobileesp.middleware.UserAgentDetectionMiddleware' ) from django_mobileesp.detector import mobileesp_agent as agent DETECT_USER_AGENTS = { 'is_android': agent.detectAndroid, 'is_ios': agent.detectIos, 'is_windows_phone': agent.detectWindowsPhone, 'is_mobile': agent.detectTierTablet | \ agent.detectTierIphone | \ agent.detectMobileQuick, }
If you prefer more pythonic methods, you can user a wrapper agent as follows:
from django_mobileesp.detector import python_agent as agent DETECT_USER_AGENTS = { 'is_android': agent.detect_android, 'is_ios': agent.detect_ios, 'is_windows_phone': agent.detect_windows_phone, 'is_mobile': agent.detect_tier_tablet | \ agent.detect_tier_iphone | \ agent.detect_mobile_quick, }
Finally access the defined attributes in your views:
def view(request): if request.is_mobile: ...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Django-Mobileesp-1.0.1.tar.gz
(10.5 kB
view details)
Built Distribution
File details
Details for the file Django-Mobileesp-1.0.1.tar.gz
.
File metadata
- Download URL: Django-Mobileesp-1.0.1.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec7b5d1332a8b73942c8be946bb75c1a857810dcef0a3f9e366d499c0df55ea4 |
|
MD5 | 028a9103f74df98f556687ffa79d8ef5 |
|
BLAKE2b-256 | ed9681bcea5ef735687e43a11ba8e5bcaa430ad2c8f86b46cab4fbd3d747ca27 |
File details
Details for the file Django_Mobileesp-1.0.1-py2-none-any.whl
.
File metadata
- Download URL: Django_Mobileesp-1.0.1-py2-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c93667a30c5f81f8a2cae97083498ab50d342392c061aa445a2d7fedd4f5a4f |
|
MD5 | fb78d376ff422d8f823115aedaf8ebeb |
|
BLAKE2b-256 | e9a9d05dd31d31a8705b741fd37adf9fce7444d1d9eeb1ebf79e12e1ef611c44 |