django-mobileesp-1.0.1
توضیحات
Detect request's mobile user agents using the mobileesp lib.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | django-mobileesp-1.0.1 |
| نام | django-mobileesp |
| نسخه کتابخانه | 1.0.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Diogo Laginha |
| ایمیل نویسنده | diogo.laginha.machado@gmail.com |
| آدرس صفحه اصلی | https://github.com/laginha/django-mobileesp |
| آدرس اینترنتی | https://pypi.org/project/django-mobileesp/ |
| مجوز | MIT |
=====================================
Django Mobileesp
=====================================
Basic usage
-----------
*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:
...
نحوه نصب
نصب پکیج whl django-mobileesp-1.0.1:
pip install django-mobileesp-1.0.1.whl
نصب پکیج tar.gz django-mobileesp-1.0.1:
pip install django-mobileesp-1.0.1.tar.gz