title: Django - How to delete a object directly from a button in a table
body: <p>(sorry for my bad english)</p>
  
  <p>I need to delete an object, but directly from a list of the objects that y have in my template.</p>
  
  <p>I have a work orders, that have spare parts but i don't know how to create the deleteview for the spare parts using only a buton in the detailview of the work order. The idea is that the user make click in the Delete button.</p>
  
  <p>This is the model of the Spare Parts</p>
  
  <pre><code>class OrderSparePart(models.Model):
      # Relations
      workorder = models.ForeignKey(
              WorkOrder,
              verbose_name=_('order'),
          )
      # Attributes - Mandatory
      spare_part = models.CharField(
              max_length=80,
              verbose_name=_('spare part'),
          )
      # Attributes - Optional
      price = models.DecimalField(
              max_digits=6,
              decimal_places=2,
              null=True,
              blank=True,
              verbose_name=_('price'),
          ) 
      # Object Manager
      # Custom Properties
      # Methods
      def get_absolute_url(self):
          return reverse('work_orders:detail', kwargs={'order_id': self.workorder.id})
  
      # Meta and String
      class Meta:
          verbose_name = _("order spare part")
          verbose_name_plural = _("order spare parts")
  </code></pre>
  
  <p>This is where is showed in the template</p>
  
  <pre><code>                  {% if spare_parts %}
                    &lt;table class="table"&gt;
                      &lt;thead&gt;
                        &lt;tr&gt;
                          &lt;th&gt;{% trans "Spare Part" %}&lt;/th&gt;
                          &lt;th&gt;{% trans "Price" %}&lt;/th&gt;
                          &lt;th&gt;{% trans "Delete" %}&lt;/th&gt;
                        &lt;/tr&gt;
                      &lt;/thead&gt;
                      &lt;tbody&gt;
                        {% for part in spare_parts %}
                        &lt;tr&gt;
                          &lt;td&gt;&lt;i class="fa fa-gear"&gt;&lt;/i&gt; {{ part.spare_part }}&lt;/td&gt;
                          {% if part.price %}
                          &lt;td&gt;$ {{ part.price }}&lt;/td&gt;
                          {% else %}
                          &lt;td&gt;&lt;/td&gt;
                          {% endif %}
                          &lt;td&gt;&lt;a href="#"&gt;&lt;i class="fa fa-trash"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/td&gt;
                        &lt;/tr&gt;
                        {% endfor %}
                      &lt;/tbody&gt;
                    &lt;/table&gt;
                  {% else %}
                  &lt;p&gt;NO HAY REPUESTOS ASENTADOS AÚN&lt;/p&gt;
                  {% endif %}
  </code></pre>
  
  <p>The the idea is use the  to delete the spare part.</p>
  
  <p>how i have to make the deleteview and the link to this???</p>
  
  <p>Thanks!</p>