O'Reilly logo

Python Geospatial Development - Second 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

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 ...

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