Welcome to Django Terralego’s documentation!¶
Getting started¶
Install using pip:
pip install terralego
Add to your INSTALLED_APPS
:
INSTALLED_APPS = [
'django_terralego',
...
]
Set your credentials in your settings:
TERRALEGO = {
'USER': 'user',
'PASSWORD': 'pass',
}
You can also disable the request made to terralego if needed:
TERRALEGO = {
'ENABLED': False,
}
Contents:
Geodirectory¶
Django Terralego provides a mixin you can add to your models to enable the geodirectory. Each model will have a geometry field which will be automatically updated to terralego after each save.
-
class
django_terralego.models.
GeoDirectoryMixin
(*args, **kwargs)¶ A model with a corresponding entry in Terralego.
The entry will be updated at every save. You can pass terralego_commit at False to force not updating the entry.
This model is designed to be one-way only. This means that it won’t update from terralego automatically. If you update the entry from somewhere else, you will have to call _update_from_terralego_entry manually.
-
save_to_terralego
()¶ Create or update the entry in terralego, adding the model_path to the tags if needed.
-
update_from_terralego_data
(data)¶ Set self.geometry and self.tags with the values in data and cache it.
Parameters: data – the geojson representing the entry
-
update_from_terralego_entry
()¶ Get the terralego entry related to self.terralego_id and update the instance tags and geometry.
-
You can use django-leaflet to add a map widget. For example for the admin site:
from leaflet.admin import LeafletGeoAdmin
class MyModelAdmin(LeafletGeoAdmin):
fields = ('terralego_geometry')
map_width = '500px'