Adding features
We'll next implement the ability to add a new feature. To do this, we'll put an Add Feature button onto the "Edit Shapefile" view. Clicking on this button will call the "Edit Feature" URL, but without a feature ID. We'll then modify the "Edit Feature" view so that if no feature ID is given, a new Feature object is created.
Open the shapefiles application's views.py module, find the edit_shapefile() function, and add the following highlighted lines to this function:
def edit_shapefile(request, shapefile_id):
try:
shapefile = Shapefile.objects.get(id=shapefile_id)
except Shapefile.DoesNotExist:
raise Http404
tms_url = "http://"+request.get_host()+"/tms/"
find_feature_url = "http://" + request.get_host() \
+ "/editor/find_feature"
add_feature_url = "http://" + request.get_host() \
+ "/edit_feature/" + str(shapefile_id)
return render(request, "select_feature.html",
{'shapefile...