'Ensure based_on is valid.'

def clean(self):

    try:
        (self.document and self.document.original)
    except Document.DoesNotExist:
        self.based_on = None
    else:
        (based_on, is_clean) = self._based_on_is_clean()
        if (not is_clean):
            if self.document.parent:
                self.based_on = self.document.parent.current_revision
            else:
                old = self.based_on
                self.based_on = based_on
                locale = settings.LOCALES[settings.WIKI_DEFAULT_LANGUAGE].native
                error = ugettext('A    revision    must    be    based    on    a    revision    of    the    %(locale)s    document.    Revision    ID    %(id)s    does    not    fit    those    criteria.')
                raise ValidationError((error % {'locale': locale, 'id': old.id}))
