O'Reilly logo

Python Geospatial Development - Third Edition by Erik Westra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Editing features

Now that we know which feature the user wants to edit, our next task is to implement the "Edit Feature" page itself. To do this, we are going to have to create a custom form with a single input field, named geometry, that uses a suitable map-editing widget for editing the feature's geometry.

The process of building this form is a bit involved, thanks to the fact that we have to create a new django.contrib.gis.forms.Form subclass on the fly to handle the different types of geometries that can be edited. Let's put this complexity into a new function within the shared.utils module, which we'll call get_map_frm().

Edit the utils.py module and type in the following code:

def get_map_form(shapefile): geometry_field = calc_geometry_field(shapefile.geom_type) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required