def _setup_pages(cls, config):
        from cms.exceptions import NoHomeFound
        from cms.models import Page
        from cms.utils import get_language_list
        from django.conf import settings
        from django.utils.translation import override
        app_page = None
        get_url = False
        if getattr(settings, 'ALDRYN_SEARCH_CMS_PAGE', False):
            from aldryn_search.search_indexes import TitleIndex
            def fake_url(self, obj):
                return ''
            get_url = TitleIndex.get_url
            TitleIndex.get_url = fake_url
        site = Site.objects.get_current()
        auto_sites = cls.auto_setup.get('sites', True)
        if auto_sites is True or site.pk in auto_sites:
            if getattr(cls, 'app_config', False):
                configs = cls.app_config.objects.all()
                if not configs.exists():
                    config = cls._create_config()
                else:
                    config = configs.first()
            langs = get_language_list(site.pk)
            if not Page.objects.on_site(site.pk).filter(application_urls=cls.__name__).exists():
                for lang in langs:
                    with override(lang):
                        if config:
                            if cls.auto_setup['config_translated_fields']:
                                cls._create_config_translation(config, lang)
                            namespace = config.namespace
                        elif cls.app_name:
                            namespace = cls.app_name
                        else:
                            namespace = None
                        try:
                            home = Page.objects.get_home(site.pk).get_draft_object()
                        except NoHomeFound:
                            home = None
                        set_home = hasattr(Page, 'set_as_homepage')
                        home = cls._create_page(
                            home, lang, cls.auto_setup['home title'], site=site, set_home=set_home
                        )
                        app_page = cls._create_page(
                            app_page, lang, cls.auto_setup['page title'], cls.__name__, home,
                            namespace, site=site
                        )
                if get_url:
                    TitleIndex.get_url = get_url