This project is inspired on these posts about Django working with mobile:
Django Mobile Browser Detection Middleware
Mobile Template Mixin for Django Class Based Views
In your settings.py add:
MOBILE_TEMPLATE_DIRS = (PROJECT_DIR.child('templates', 'mobile'),)
DESKTOP_TEMPLATE_DIRS = (PROJECT_DIR.child('templates', 'desktop'),)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
#add middleware to support mobile detection
'myapp.middleware.RequestDetectionMiddleware',
)
In your view.py add:
from .mobile_mixin import MobileTemplateMixin
class YourView(MobileTemplateMixin):
template_name = "app/template.html"