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) ...
Get Python Geospatial Development - Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.