{ "info": { "author": "calband", "author_email": "calband-compcomm@lists.berkeley.edu", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "=============\ndjango-mobile\n=============\n\n|build| |package|\n\n.. _introduction:\n\n**django-mobile** provides a simple way to detect mobile browsers and gives\nyou tools at your hand to render some different templates to deliver a mobile\nversion of your site to the user.\n\nThe idea is to keep your views exactly the same but to transparently\ninterchange the templates used to render a response. This is done in two\nsteps:\n\n1. A middleware determines the client's preference to view your site. E.g. if\n he wants to use the mobile flavour or the full desktop flavour.\n2. The template loader takes then care of choosing the correct templates based\n on the flavour detected in the middleware.\n\n\nInstallation\n============\n\n.. _installation:\n\n*Pre-Requirements:* ``django_mobile`` depends on django's session framework. So\nbefore you try to use ``django_mobile`` make sure that the sessions framework\nis enabled and working.\n\n1. Install ``django_mobile`` with your favourite python tool, e.g. with\n ``easy_install django_mobile`` or ``pip install django_mobile``.\n2. Add ``django_mobile`` to your ``INSTALLED_APPS`` setting in the\n ``settings.py``.\n3. Add ``django_mobile.middleware.MobileDetectionMiddleware`` to your\n ``MIDDLEWARE_CLASSES`` setting.\n4. Add ``django_mobile.middleware.SetFlavourMiddleware`` to your\n ``MIDDLEWARE_CLASSES`` setting. Make sure it's listed *after*\n ``MobileDetectionMiddleware`` and also after ``SessionMiddleware``.\n5. Add ``django_mobile.loader.Loader`` as first item to your\n ``loaders`` list for ``TEMPLATES`` setting in ``settings.py``.\n6. Add ``django_mobile.context_processors.flavour`` to your\n ``context_processors`` list for ``TEMPLATES`` setting. You can read more about ``loaders`` and ``context_processors`` in `Django docs`_.\n\n*Note:* If you are using Django 1.7 or older, you need to change step 5 and 6 slightly. Use the ``TEMPLATE_LOADERS`` and ``TEMPLATE_CONTEXT_PROCESSORS`` settings instead of ``TEMPLATES``.\n\nNow you should be able to use **django-mobile** in its glory. Read below of how\nthings work and which settings can be tweaked to modify **django-mobile**'s\nbehaviour.\n\n\nUsage\n=====\n\n.. _flavours:\n\nThe concept of **django-mobile** is build around the ideas of different\n*flavours* for your site. For example the *mobile* version is described as\none possible *flavour*, the desktop version as another.\n\nThis makes it possible to provide many possible designs instead of just\ndifferentiating between a full desktop experience and one mobile version. You\ncan make multiple mobile flavours available e.g. one for mobile safari on the\niPhone and Android as well as one for Opera and an extra one for the internet\ntablets like the iPad.\n\n*Note:* By default **django-mobile** only distinguishes between *full* and\n*mobile* flavour.\n\nAfter the correct flavour is somehow chosen by the middlewares, it's\nassigned to the ``request.flavour`` attribute. You can use this in your views\nto provide separate logic.\n\nThis flavour is then use to transparently choose custom templates for this\nspecial flavour. The selected template will have the current flavour prefixed\nto the template name you actually want to render. This means when\n``render_to_response('index.html', ...)`` is called with the *mobile* flavour\nbeing active will actually return a response rendered with the\n``mobile/index.html`` template. However if this flavoured template is not\navailable it will gracefully fallback to the default ``index.html`` template.\n\nIn some cases its not the desired way to have a completely separate templates\nfor each flavour. You can also use the ``{{ flavour }}`` template variable to\nonly change small aspects of a single template. A short example:\n\n.. code-block:: html+django\n\n \n
\n