'Dodge cascading delete of documents and other revisions.'

def delete(self, *args, **kwargs):

    def latest_revision(excluded_rev, constraint):
        "Return    the    largest-ID'd    revision    meeting    the    given    constraint\n                                                and    excluding    the    given    revision,    or    None    if    there    is    none."
        revs = document.revisions.filter(constraint).exclude(pk=excluded_rev.pk).order_by('-id')[:1]
        try:
            return revs[0]
        except IndexError:
            return None
    Revision.objects.filter(based_on=self).update(based_on=None)
    document = self.document
    if (document.current_revision == self):
        new_current = latest_revision(self, Q(is_approved=True))
        document.update(current_revision=new_current, html=(new_current.content_parsed if new_current else ''))
    if (document.latest_localizable_revision == self):
        document.update(latest_localizable_revision=latest_revision(self, Q(is_approved=True, is_ready_for_localization=True)))
    super(Revision, self).delete(*args, **kwargs)
