'Return the previous Release to this one.
:return: the previous :class:`Release`, or None'

def previous(self):

    releases = self.app.release_set
    if self.pk:
        releases = releases.exclude(pk=self.pk)
    try:
        prev_release = releases.latest()
    except Release.DoesNotExist:
        prev_release = None
    return prev_release
