This is the django app that powers api.opencivicdata.org
Python 3.3 or newer required, Python 2 compatibility is not guaranteed.
- Install Represent Boundaries.
- Add
'imago'to yourINSTALLED_APPS. - Add
('', include('imago.urls')),tourls.py.
Imago's loadmappings management command loads mappings between divisions managed by opencivicdata-django and boundaries managed by Represent Boundaries. If mappings are not loaded, then the lat and lon filters on the /people/ and /divisions/ endpoints will not work, and geometries will not appear on the /divisions/ endpoint. For the command to succeed, you must set the IMAGO_COUNTRY and IMAGO_BOUNDARY_MAPPINGS settings:
- Set
IMAGO_COUNTRYto a two-letter, lowercase country code like'us'insettings.py, to select which country's Open Civic Data Division Identifiers to use. - Set
IMAGO_BOUNDARY_MAPPINGSinsettings.py, a dictionary in which each key is the slug of a boundary set and each value is a dictionary, which has as keys:key: The property of a division identifier that will be used for matching.boundary_key: Optional. Defaults toexternal_id. The property of a boundary that will be used for matching, or a lambda that takes a boundary as an argument and returns a string that will be used for matching.prefix: Imago will prepend this prefix to the property of the boundary, identified byboundary_key, and will look for the division identifier whose property, identified bykey, matches.ignore: Optional. A regular expression string. If no match is found, and if eitherignoreis missing or the boundary name doesn't match the regular expression, a warning will be issued about the unmatched boundary.
See api.opencivicdata.org's settings.py for an example.