def clean(self):
    '\n        Validates that either the slug is provided, or that slugification from\n        `title` produces a valid slug.\n        :return:\n        '
    cleaned_data = super(CreateCMSPageForm, self).clean()
    slug = cleaned_data.get('slug')
    sub_page = cleaned_data.get('sub_page')
    title = cleaned_data.get('title')
    if self.page:
        if sub_page:
            parent = self.page
        else:
            parent = self.page.parent
    else:
        parent = None
    if slug:
        starting_point = slug
    elif title:
        starting_point = title
    else:
        starting_point = _('page')
    slug = generate_valid_slug(starting_point, parent, self.language_code)
    if (not slug):
        raise forms.ValidationError('Please provide a valid slug.')
    cleaned_data['slug'] = slug
    return cleaned_data
Validates that either the slug is provided, or that slugification from
`title` produces a valid slug.
:return:
def clean(self):
    '\n        Validates that either the slug is provided, or that slugification from\n        `title` produces a valid slug.\n        :return:\n        '
    cleaned_data = super(CreateCMSPageForm, self).clean()
    slug = cleaned_data.get('slug')
    sub_page = cleaned_data.get('sub_page')
    title = cleaned_data.get('title')
    if self.page:
        if sub_page:
            parent = self.page
        else:
            parent = self.page.parent
    else:
        parent = None
    if slug:
        starting_point = slug
    elif title:
        starting_point = title
    else:
        starting_point = _('page')
    slug = generate_valid_slug(starting_point, parent, self.language_code)
    if (not slug):
        raise forms.ValidationError('Please provide a valid slug.')
    cleaned_data['slug'] = slug
    return cleaned_data