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 hashes)
Built Distribution
Close
Hashes for Django_Mobileesp-1.0.1-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c93667a30c5f81f8a2cae97083498ab50d342392c061aa445a2d7fedd4f5a4f |
|
MD5 | fb78d376ff422d8f823115aedaf8ebeb |
|
BLAKE2b-256 | e9a9d05dd31d31a8705b741fd37adf9fce7444d1d9eeb1ebf79e12e1ef611c44 |