Skip to main content

Django-mobile-template

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>.

Metadata

Release files for django-mobile-template 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-mobile-template 0.1
File Size Uploaded
django-mobile-template-0.1.tar.gz 2.8 kB Details

Release files / django-mobile-template-0.1.tar.gz

Download URL django-mobile-template-0.1.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d39b02f726dfd1381687c455521ed069c4be3e4926401c46df6d69b10279db98
BLAKE2b-256 checksum
How to use checksums
b283051e24edeaf21d46ac11f2e45113d7a82978e3636689fd5e61ce9efa73a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page