GeoDjango is a world-class geographic Web Framework. GeoDjango is a part of contrib module of Django. It is useful to create geographic web applications.
The framework is loosely coupled with high-level Python interfaces for GIS geometry and raster operations. It eases data manipulation in different formats.
It is simple to create geometry fields editing from the admin module.
GeoDjango also supplements the Django admin by allowing users to create and modify geometries on a JavaScript slippy map.
Let’s dive into some dirty coding work.
Create a file called admin.py inside a web application with the following code:
from django.contrib.gis import admin
from .models import WorldBorder
admin.site.register(WorldBorder, admin.GeoModelAdmin)
Edit the urls.py in the geodjango application folder as follows:
from django.contrib.gis import admin
from django.urls import include, path
urlpatterns = [
path('admin/', admin.site.urls),
]
Create an admin user:
$ python manage.py createsuperuser
Start the Django development server:
$ python manage.py runserver
Now browse http://localhost:8000/admin/, and log in with the user created above. The geometries can be edited by clicking on a polygon and dragging the vertices to the desired position.
Questions?
Write to bd@agilytics.in for more details to build your web app in Python and Django.
Comments