rapidsms.contrib.locations

Warning

The fate of rapidsms.contrib.locations is currently up for debate in the RapidSMS community. It has been updated to run in RapidSMS v0.12.0+, but not all functionality is supported. If you’re interested in contributing to Locations, please see this message thread.

Locations allows you to easily map custom locations and points in your i RapidSMS project.

Installation

  1. The locations contrib application depends on djtables to display data. You can install djtables using pip:
pip install djtables
  1. Add "rapidsms.contrib.locations" and "djtables" (if not already present) to INSTALLED_APPS in your settings file:

    INSTALLED_APPS = [
        ...
        "rapidsms.contrib.locations",
        "djtables",
        ...
    ]
    
  2. Add locations URLs to your urlconf:

    urlpatterns = patterns("",
        ...
        (r"^locations/", include("rapidsms.contrib.locations.urls")),
        ...
    )
    
  3. Create database tables for the locations models:

$ python manage.py syncdb
  1. If wanted, add a navigation item to your rapidsms/_nav_bar.html template:
{% load url from future %}
<li><a href="{% url "locations" %}">Map</a></li>

Usage

Locations will auto-generate a map and editing interface for any models that inherit from rapidsms.contrib.locations.models.Location. For example, say you had an application called cities with a City model:

# example file: cities/models.py

from django.db import models
from rapidsms.contrib.locations.models import Location

class City(Location):
    name = models.CharField(max_length=100)

    class Meta(object):
        app_label = "cities"
        verbose_name_plural = "cities"

To use Locations, you’d add cities to your installed apps:

INSTALLED_APPS = [
    ...
    "cities",
    ...
]

Create the necessary database tables:

$ python manage.py syncdb

Now visit the Map tab in your browser to see the City model.

RapidSMS is a free and open-source framework for dynamic data collection, logistics coordination and communication, leveraging basic short message service (SMS) mobile phone technology.

Getting Help

Related Topics

Table Of Contents