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 shapefiles.views module and add the following to the top of the edit_feature() ...

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.