Simple app that dynamically changes the templates based on domain/subdomain.
Project description
Simple django app that dynamically change template_name
of your view based on domain name
(e.g example.com and m.example.com).
Useful in case if you already have third party service that redirects to the mobile version of your site.
Installation
pip install django-mobile-template
# OR
pip install git+https://github.com/linevich/django-mobile-template.git
INSTALLED_APPS = [
...
'mobile_template',
...
]
Usage
Please note: MobileTemplateView
should be first parent class.
# views.py
from django.views.generic import TemplateView
from mobile_template.views import MobileTemplateView
class Home(MobileTemplateView, TemplateView):
template_name = 'index.html'
Templates folder structure:
templates
├── base.html
├── index.html
└── mobile
└── index.html
Configuration
MOBILE_TEMPLATES_PREFIX
(Default:mobile/
) — mobile templates subfolder.MOBILE_DOMAIN_REGEX
(Default:^m.\.*.\.*.*'
) — regular expression to capture mobile domains. By default it captures all domains started with m.<domain_or_subdomain>.
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
File details
Details for the file django-mobile-template-0.1.tar.gz
.
File metadata
- Download URL: django-mobile-template-0.1.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d39b02f726dfd1381687c455521ed069c4be3e4926401c46df6d69b10279db98 |
|
MD5 | 63f659fc1335fdf38be8081d8f32048a |
|
BLAKE2b-256 | b283051e24edeaf21d46ac11f2e45113d7a82978e3636689fd5e61ce9efa73a3 |