Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install django-devicetype-templates

How to install django-devicetype-templates

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install django-devicetype-templates
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
Windows (64-bit)
Mac OS X (10.5+)
0.1.7 Available View build log
Linux (32-bit)
0.1.7 Available View build log
0.1.2 Available View build log
Linux (64-bit)
0.1.7 Available View build log
0.1.7 Available View build log
 
Author
License
BSD
Imports
Lastest release
version 0.1.7 on May 4th, 2013

django-devicetype-templates is a library that detect device type by browser's user agent string and serves different templates for each type.

If standard responsive layouts does not fit all of your needs and if you do not want to use some hacky template loaders with thread locals, you may find this library useful.

Requirements

Installation

Install from PyPi:

pip install django-devicetype-templates

Install development version to virtualenv:

git clone https://github.com/whit/django-devicetype-templates.git
cd django-devicetype-templates
python setup.py develop

Run tests:

python setup.py nosetests

Configuration

Add middleware:

MIDDLEWARE_CLASSES = (
    ...
    'devicetype.middleware.DeviceTypeMiddleware',
)

If you need to use some variables in your templates, you can add devicetype context processor:

TEMPLATE_CONTEXT_PROCESSORS = (
    ...
    'devicetype.context_processors.devicetype',
)

Then, in templates will be available these variables: devicetype, is_mobile and big_resolution (not implemented yet).

Other settings

DEVICETYPE_TEMPLATE_PREFIX

Prefixes are variable. When you need prefix template file name, use something like tablet-. If you want to have device-specific templates in subfolders, you can use tablet/ prefix for example.

Default:

{
    'desktop': '',
    'mobile': 'mobile/',
    'tablet': 'tablet/',
}

DEVICETYPE_PREFIX_BASENAME

When you use folder-like prefix, like tablet/ and mobile/, with this setting you can select how subfolders will be detected.

With DEVICETYPE_PREFIX_BASENAME = False (default):

tablet/base.html
tablet/app/app_base.html
tablet/layout/three-cols.html
...

With DEVICETYPE_PREFIX_BASENAME = True:

tablet/base.html
app/tablet/app_base.html
layout/tablet/three-cols.html
...

DEVICETYPE_MOBILE_PATTERNS and DEVICETYPE_TABLET_PATTERNS

You can override default search patterns. It search in tablet patterns first.

Build status

Master branch:Travis CI - Distributed build platform for the open source community

Subscribe to package updates

Last updated May 4th, 2013

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.