Helps django developers to support mobile users, features:
- Detection of requests starting with m. or mobile.yoursite.com
- Detection of requests with HTTP_USER_AGENT of mobile browsers
- Decorator to provide a simple way provide template for mobile devices
See project page for more.
Download the code; put in into your project’s directory,
if you want a system-wide instalation you can run
python setup.py installor
sudo easy_install django-mobile-helper
REQUIREMENTS: django !
Regular expression to match mobile user in HTTP_USER_AGENT header.
default: (up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|windows ce|pda|mobile|mini|palm|netfront)
In your settings.py add:
MIDDLEWARE_CLASSES = (
(…) #your middleware classes
# if you added to you project’s folder:
‘your_project.django_mobile.middleware.MobileMiddleware’
# if you installed on site-packages:
‘django_mobile.middleware.MobileMiddleware’
)
You can use it in any view function:
from django_mobile.middleware import MobileMiddleware
@login_required
@render_to(template=‘desktop.html’, mobile_template=‘mobile_template.html’)
def view_function(request):
(…) # do your stuff here
return locals()