<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def delete_object(self, obj, post_delete=False):
 """Delete an object with Discipline Only argument is a Django object. Analogous to Editor.save_object. """

        # Collect related objects that will be deleted by cascading
        links = [rel.get_accessor_name() for rel in \
                 obj._meta.get_all_related_objects()]
        # Recursively delete each of them
        for link in links:
            objects = getattr(obj, link).all()
            for o in objects:
                self.delete_object(o, post_delete)
        # Delete the actual object
        self._delete_object(obj, post_delete)