rapidsms.contrib.locations

Warning

rapidsms.contrib.locations will be removed from contrib in the next version of RapidSMS.

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.