Skip to main content

Simple app that dynamically changes the templates based on domain/subdomain.

Project description

https://travis-ci.org/linevich/django-mobile-template.svg?branch=master

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

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-mobile-template-0.1.tar.gz (2.8 kB view details)

Uploaded Source

File details

Details for the file django-mobile-template-0.1.tar.gz.

File metadata

File hashes

Hashes for django-mobile-template-0.1.tar.gz
Algorithm Hash digest
SHA256 d39b02f726dfd1381687c455521ed069c4be3e4926401c46df6d69b10279db98
MD5 63f659fc1335fdf38be8081d8f32048a
BLAKE2b-256 b283051e24edeaf21d46ac11f2e45113d7a82978e3636689fd5e61ce9efa73a3

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