'Set all pending versions older than this one attached to the same
Extension as STATUS_OBSOLETE.
To be on the safe side this method does not trigger signals and needs
to be called when creating a new pending version, before actually
changing its status to PENDING. That way we avoid having extra versions
laying around when we automatically update the status on the parent
Extension.'

def set_older_pending_versions_as_obsolete(self):

    qs = self.__class__.objects.without_deleted().pending().filter(extension=self.extension, pk__lt=self.pk)
    qs.update(status=STATUS_OBSOLETE)
