title: Override delete_selected() and update fields of child model
body: <p>I'm trying to override the delete method for a model named Invoice. Model Invoice is referenced by ForeignKey in model Action. I want to update a BooleanField named billed in model Admin when it's Invoice is deleted </p>
  
  <p>the solution described in this post:</p>
  
  <p><a href="https://stackoverflow.com/questions/1534986/how-do-i-override-delete-on-a-model-and-have-it-still-work-with-related-delete">How do I override delete() on a model and have it still work with related deletes</a></p>
  
  <p>that answer:
  <a href="https://stackoverflow.com/a/1539182">https://stackoverflow.com/a/1539182</a></p>
  
  <p>is not working for me like this in models.py:</p>
  
  <pre><code>def delete(self):
        Action.objects.filter(invoice=self).update(billed=False) # and tried 0 instead of False
        super(Invoice,self).delete()
  </code></pre>
  
  <p>also tried:</p>
  
  <pre><code>def delete(self):
       actions = Action.objects.filter(invoice=self)
       for action in actions:
          action.billed=False   # and tried 0 instead of False
          action.save()
       super(Invoice,self).delete()
  </code></pre>
  
  <p>The ForeignKey Field in Model Action has a on_delete=models.SET_NULL to avoid to delete actions when the invoice is deleted. But I also need to set billed back to False.</p>
  
  <pre><code>invoice = models.ForeignKey( Invoice, verbose_name = 'Rechnung', null=True, blank=True,on_delete=models.SET_NULL)
  </code></pre>
  
  <p>I just read here <a href="https://code.djangoproject.com/ticket/10751" rel="nofollow noreferrer">https://code.djangoproject.com/ticket/10751</a> that in Admin the action delete selected could not be overridde with delete()</p>
  
  <p>I have to use delete_view() instead</p>
  
  <p>So I tried</p>
  
  <pre><code>def delete_selected(self, request, obj, extra_context=None):
      Action.objects.filter(invoice=self).update(billed=False)
      super(InvoiceAdmin, self).delete_view(request, obj, extra_context)
  </code></pre>
  
  <p>Also tried to use obj instead of self, but not the solution</p>