Wednesday, October 15, 2014

Django JQuery Mobile Setup

Django JQuery Mobile Setup

This document describes how to create a new Django project for use with the django-jqm quick-start templates. If you have an existing Django project, the steps can be simplified to:
  • install django-jqm (and optionally django-html5 if you want to use HTML5 native widgets)
  • add “jqm” to your installed applications
  • add the standard auth, static and request template context handlers
You can then continue to Basic View (with Login/Logout).

Host Setup

Project setup (for an Ubuntu Server or Debian Host), obviously you’ll need to be root to do this:
$ aptitude install python-pip python-virtualenv git bzr

VirtualEnv Setup

Set up a virtualenv with django-html5, django-jqm, and, of course, django:
$ virtualenv jqm-tutorial
$ source jqm-tutorial/bin/activate
$ pip install "django>=1.3"
$ pip install -e "git+"
$ pip install -e "bzr+"

Django Project Configuration

At this point you should have a virtualenv with Django installed, so let’s create a very basic project:
$ startproject tutorial
We’ll now edit the auto-started project’s to:
  • add jqm to the installed apps set (so that its templates will be available)
  • provide a basic database configuration
  • enable common context processors for templates
  • provide a default “on login” landing page (for now, ‘/’)
Basic database configuration:
    'default': {
        'ENGINE': 'sqlite3',
        'NAME': 'tutorial.db',
        # ...
A directory for our project-level templates:
TEMPLATE_DIR = '/'.join([
    os.path.abspath( os.path.dirname( __file__ )),
Common context processors (note, only auth, static and request are actually required by django-jqm):
Add the following to INSTALLED_APPS:
Finally, provide a default landing-page URL for post-login views:
You should now be able to continue to Basic View (with Login/Logout).

No comments:

Post a Comment