Django Packages that make it easier to work with geographical information system projects
- Mar 20, 2022
Django model field that can hold a geoposition, and corresponding widget
from django.db import models from geoposition.fields import GeopositionField class PointOfInterest(models.Model): name = models.CharField(max_length=100) position = GeopositionField()

Location field and widget for Django. It supports Google Maps, OpenStreetMap and Mapbox
Features
- Support for multiple map engines, like Google Maps, OpenStreetMap and Mapbox.
- Support for multiple search engines, like Google, Nominatim, Yandex and Addok.
- Works with both Spatial and non-Spatial databases.
Basic usage (using Spatial Database)
from django.contrib.gis.db import models from django.contrib.gis.geos import Point from location_field.models.spatial import LocationField class Place(models.Model): city = models.CharField(max_length=255) location = LocationField(based_fields=['city'], zoom=7, default=Point(1.0, 1.0))

Geodata extensions for Django REST Framework
Add vector response formats such as GeoJSON, KML/KMZ, and SVG to your API.
# models.py from django.contrib.gis.db import models from spillway.query import GeoQuerySet class Location(models.Model): slug = models.SlugField() geom = models.GeometryField() objects = GeoQuerySet.as_manager() # urls.py from django.conf.urls import url from spillway import generics from .models import Location urlpatterns = [ url(r'^locations/(?P<slug>[\w-]+)/$', generics.GeoDetailView.as_view(queryset=Location.objects.all()), name='location'), url(r'^locations/$', generics.GeoListView.as_view(queryset=Location.objects.all()), name='location-list'), ]
Geographic add-ons for Django REST Framework. Maintained by the OpenWISP Project.
For example, the following model:
class Location(models.Model): """ A model which holds information about a particular location """ address = models.CharField(max_length=255) city = models.CharField(max_length=100) state = models.CharField(max_length=100) point = models.PointField()django django-rest-framework geojson gis hacktoberfest python