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.
pip install djtables
Add "rapidsms.contrib.locations" and "djtables" (if not already present) to INSTALLED_APPS in your settings file:
INSTALLED_APPS = [
...
"rapidsms.contrib.locations",
"djtables",
...
]
Add locations URLs to your urlconf:
urlpatterns = patterns("",
...
(r"^locations/", include("rapidsms.contrib.locations.urls")),
...
)
Create database tables for the locations models:
$ python manage.py syncdb
{% load url from future %}
<li><a href="{% url "locations" %}">Map</a></li>
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.