Skip to main content

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


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)

Uploaded Source

Built Distribution

Django_Mobileesp-1.0.1-py2-none-any.whl (12.2 kB view details)

Uploaded Python 2

File details

Details for the file Django-Mobileesp-1.0.1.tar.gz.

File metadata

File hashes

Hashes for Django-Mobileesp-1.0.1.tar.gz
Algorithm Hash digest
SHA256 ec7b5d1332a8b73942c8be946bb75c1a857810dcef0a3f9e366d499c0df55ea4
MD5 028a9103f74df98f556687ffa79d8ef5
BLAKE2b-256 ed9681bcea5ef735687e43a11ba8e5bcaa430ad2c8f86b46cab4fbd3d747ca27

See more details on using hashes here.

File details

Details for the file Django_Mobileesp-1.0.1-py2-none-any.whl.

File metadata

File hashes

Hashes for Django_Mobileesp-1.0.1-py2-none-any.whl
Algorithm Hash digest
SHA256 6c93667a30c5f81f8a2cae97083498ab50d342392c061aa445a2d7fedd4f5a4f
MD5 fb78d376ff422d8f823115aedaf8ebeb
BLAKE2b-256 e9a9d05dd31d31a8705b741fd37adf9fce7444d1d9eeb1ebf79e12e1ef611c44

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page