Deleting features
We next want to let the user delete an existing feature. To do this, we'll add a Delete Feature button to the edit feature
view. Clicking on this button will redirect the user to the delete feature
view for that feature.
Edit the edit_feature.html
template, and add the following highlighted lines to the <form>
section of the template:
<form method="POST" action=""> <table> <tr> <td></td> <td align="right"> <input type="submit" name="delete" value="Delete Feature"/> </td> </tr> {{ form.as_table }} ...
Notice that we've used <input type="submit">
for this button. This will submit the form, with an extra POST parameter named delete
. Now go back to the editor
application's views.py
module again, and add the following to the top of the edit_feature()
function:
if request.method == "POST" and "delete" in request.POST: return HttpResponseRedirect...