This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

This is an alternative admin interface for Django for use with mobile devices such as the iPhone/iPod touch or Blackberry. Some would call it a theme or a skin, but actually it’s more than that.

It resembles almost all features of the regular Django admin interface and brings everything you need to add support for arbitrary devices.

I hope you like it.

Download & Installation

Get the source from the application site at:

To install the mobileadmin, follow these steps:

  1. Follow the instructions in the INSTALL.txt file

  2. Add 'mobileadmin' to the INSTALLED_APPS setting of your Django site. That might look like this:

       # ...
  3. Make sure you’ve installed the admin contrib app.

  4. Add 'mobileadmin.context_processors.user_agent' to your TEMPLATE_CONTEXT_PROCESSORS setting. It should look like this:



Since mobileadmin follows the ideas of Django’s admin interface you can easily reuse your existing admin setup:

You use the default or custom ModelAdmin classes for each model you wanted to be editable in the admin interface and hooked up Django’s default AdminSite instance with your URLconf.

If that’s the case you are able to re-use those ModelAdmin (sub-)classes by using mobileadmin’s separate admin site instance and its autoregister() function.

  1. In your root URLconf – just below the line where Django’s admin.autodiscover() gets called – import mobileadmin and call the function mobileadmin.autoregister():

    from django.conf.urls.defaults import *
    from django.contrib import admin
    import mobileadmin
    urlpatterns = patterns('',

    This registers your existing admin configuration with mobileadmin.

  2. Extend the urlpatterns to hook the default MobileAdminSite instance` with your favorite URL, e.g. /ma/. Add:

    urlpatterns += patterns('',

    mobileadmin is now replicating all of the regular admin features and uses templates adapted to the mobile device you are using.

  3. Set the handler404 and handler500 variables in your URLConf to the views that are provided by mobileadmin:

    handler404 = 'mobileadmin.views.page_not_found'
    handler500 = 'mobileadmin.views.server_error'

    That is needed to load the 404.html and 500.html templates according to the user agent of the browser on your mobile device. It has an automatic fallback to Django’s default error handlers.

Extending mobileadmin

mobileadmin comes with a default set of templates and patterns to recognize different devices and platforms:

  • Mobile Safari (iPhone/iPod touch)

But it’s made for being extended.

Since the template loading depends on the user agent of the requesting client, mobileadmin tells Django to look for three templates, when trying to render one of the default admin views:

  1. mobileadmin/USER_AGENT_NAME/VIEW_TEMPLATE.html
  2. mobileadmin/VIEW_TEMPLATE.html
  3. admin/index.html


  • USER_AGENT is the short name of the user agent
  • VIEW_TEMPLATE is the name of the rendered template

If you would try to access the login view with the iPhone for example, the following three templates would be tried to load:

  1. mobileadmin/mobile_safari/login.html
  2. mobileadmin/login.html
  3. admin/index.html

..where mobile_safari is the name of one of the default device patterns and login.html the name of the to needed template.

Creating a custom mobileadmin setup

You can add support for more user agents by adding MOBILEADMIN_USER_AGENTS to your file – consisting of a short name and a regualar expression, matching that user agent string:

    'my_user_agent': r'.*MyUserAgent.*',

With that it would automatically check if the regular expression matches with the user agent of the current request and – if yes – try to load the templates mobileadmin/my_user_agent/login.html, when accessing the the login page – falling back to my_user_agent/login.html and later to admin/login.html, if not found.

Have a look at TEMPLATE_MAPPING in mobileadmin/conf/ if you want to know the default regular expressions.

mobileadmin comes with a MobileAdminSite and a MobileModelAdmin class that uses the default TEMPLATE_MAPPING and USER_AGENTS settings out of the box:

from mobileadmin import sites

class MyMobileAdminSite(sites.MobileAdminSite):
    # define here whatever function you want

But if you want to use the ability of mobileadmin to change the template depending on the user agent, you need to modify a bit of your admin classes.

Luckily mobileadmin comes with a decorator to be used on AdminSite or ModelAdmin methods that changes the template of that method according to the current user agent by using a template mapping, which can be found in mobileadmin/conf/ in the TEMPLATE_MAPPING variable.

Those mappings are used by the decorator mobile_templates that applies them on the corresponding methods of your own AdminSite or ModelAdmin, e.g.:

from django.contrib.admin import sites
from mobileadmin.decorators import mobile_templates

class MyAdminSite(sites.AdminSite):

    def index(self, request, extra_context=None):

        # self.index_template is already automatically set here
        # do something cool here

        return super(MyAdminSite, self).index(request, extra_context)
    index = mobile_templates(index)

Furthermore the default mappings can be extended in your site

    'index': ('index_template', 'index.html'),


  • index is the name of the function, whose class attribute and
  • index_template (an attribute of the method’s class) would be set to the the file index.html.

Using custom mobile admin interfaces

In case you created your own mobile admin interface, you can use mobileadmin’s subclasses of Django’s ModelAdmin, InlineModelAdmin and AdminSite classes, that include the neccesary bits to make it work.

Just use it as you would use the base classes, e.g.:

from mobileadmin import options
from myproject.myapp.models import Author

class MobileAuthorAdmin(options.MobileModelAdmin):
    pass, MobileAuthorAdmin)

Then import mobileadmin in your URLconf to instantiate a MobileAdminSite object, use Django’s autodiscover() to load INSTALLED_APPS modules and add an URL for the mobileadmin to the URLConf:

from django.conf.urls.defaults import *
from django.contrib import admin
import mobileadmin


urlpatterns = patterns('',

Media path

Please feel free to use some nice little helpers to find the path to mobileadmin’s media directory. If you are using Django (or any other Python software) to serve static files (which you shouldn’t in production) just use for example:

from mobileadmin.conf import settings

mobileadmin_media_path = settings.MEDIA_PATH
mobileadmin_media_prefix = settings.MEDIA_PREFIX

You now have the full (platform-independent) path to the media directory of mobileadmin in the variable mobileadmin_media_path and the default URL prefix ('/mobileadmin_media/') for the mobileadmin media – CSS, Javascript and images – in mobileadmin_media_prefix. Just like the ADMIN_MEDIA_PREFIX but for the media directory of the mobileadmin app.

You can of course optionally override the default URL prefix by setting a MOBILEADMIN_MEDIA_PREFIX in the file of your Django site. Please use a trailing slash. This makes updating mobileadmin much easier for you, since you now don’t have to bother about different locations of the media directory.

Serving mobileadmin’s static media

Even though using Django’s ability to serve static files is strongly NOT RECOMMENDED for live production servers, it might be helpful to bring up mobileadmin for a test drive or an intranet website. Just add the following code to the URLConf ( of your Django site:

from mobileadmin.conf import settings

urlpatterns += patterns('django.views.static',
    (settings.MEDIA_REGEX, 'serve', {'document_root': settings.MEDIA_PATH}),

See how mobileadmin’s own settings module is loaded at the top of the snippet that enables you to obtain a ready-made regex for the static files (MEDIA_REGEX) and the platform-independent filesystem path to the media files (MEDIA_PATH).


Please leave your questions and problems on the designated Google Code site.

Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More


History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-mobileadmin-0.5.2.tar.gz (30.9 kB) Copy SHA256 Checksum SHA256 Source Sep 8, 2008

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting