當前位置: 首頁>>代碼示例>>Python>>正文


Python settings.INSTALLED_APPS屬性代碼示例

本文整理匯總了Python中django.conf.settings.INSTALLED_APPS屬性的典型用法代碼示例。如果您正苦於以下問題:Python settings.INSTALLED_APPS屬性的具體用法?Python settings.INSTALLED_APPS怎麽用?Python settings.INSTALLED_APPS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在django.conf.settings的用法示例。


在下文中一共展示了settings.INSTALLED_APPS屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _autodiscover

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import INSTALLED_APPS [as 別名]
def _autodiscover(recipes):
    import copy
    from django.conf import settings

    try:
        # py27 / py3 only
        from importlib import import_module
    except ImportError:
        from django.utils.importlib import import_module

    from django.utils.module_loading import module_has_submodule

    for app in settings.INSTALLED_APPS:
        mod = import_module(app)
        try:
            before_import_recipes = copy.copy(recipes)
            import_module('%s.badgify_recipes' % app)
        except Exception:
            recipes = before_import_recipes
            if module_has_submodule(mod, 'badgify_recipes'):
                raise 
開發者ID:ulule,項目名稱:django-badgify,代碼行數:23,代碼來源:registry.py

示例2: render

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import INSTALLED_APPS [as 別名]
def render(self, context):
        allowed = False
        for app in self.apps:

            if app.startswith('"') and app.endswith('"'):
                app = app[1:-1]

            if app.startswith("'") and app.endswith("'"):
                app = app[1:-1]

            if app in settings.INSTALLED_APPS:
                allowed = True
            else:
                break

        if allowed:
            return self.nodelist_true.render(context)
        else:
            return self.nodelist_false.render(context) 
開發者ID:awemulya,項目名稱:kobo-predict,代碼行數:21,代碼來源:filters.py

示例3: active_status

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import INSTALLED_APPS [as 別名]
def active_status(self, request):
        """
        This will only work if you have django-celery installed (for now).
        In case you only need to work with status codes to find out if the
        workers are up or not.
        This will only work if we assume our db only contains "active workers".
        To use this feature, you must ensure you use only named workers,
        For example: "-n worker1@localhost:8000".
        http://docs.celeryproject.org/en/latest/userguide/workers.html#starting-the-worker
        """

        app_installed = "djcelery" in settings.INSTALLED_APPS
        if not app_installed:
            return Response(status=status.HTTP_501_NOT_IMPLEMENTED)

        from djcelery.models import WorkerState

        count_workers = WorkerState.objects.all().count()
        result = self.inspect.active()

        if result is not None and count_workers == len(result):
            return Response(status=status.HTTP_200_OK)

        return Response(status=status.HTTP_404_NOT_FOUND) 
開發者ID:psychok7,項目名稱:django-celery-inspect,代碼行數:26,代碼來源:viewsets.py

示例4: get_app_template_dir

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import INSTALLED_APPS [as 別名]
def get_app_template_dir(app_name):
    """Get the template directory for an application

    We do not use django.db.models.get_app, because this will fail if an
    app does not have any models.

    Returns a full path, or None if the app was not found.
    """
    from django.conf import settings
    from importlib import import_module
    if app_name in _cache:
        return _cache[app_name]
    template_dir = None
    for app in settings.INSTALLED_APPS:
        if app.split('.')[-1] == app_name:
            # Do not hide import errors; these should never happen at this point
            # anyway
            mod = import_module(app)
            template_dir = join(abspath(dirname(mod.__file__)), 'templates')
            break
    _cache[app_name] = template_dir
    return template_dir 
開發者ID:82Flex,項目名稱:DCRM,代碼行數:24,代碼來源:template.py

示例5: setup

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import INSTALLED_APPS [as 別名]
def setup(set_prefix=True):
    """
    Configure the settings (this happens as a side effect of accessing the
    first setting), configure logging and populate the app registry.
    Set the thread-local urlresolvers script prefix if `set_prefix` is True.
    """
    from django.apps import apps
    from django.conf import settings
    from django.urls import set_script_prefix
    from django.utils.log import configure_logging

    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
    if set_prefix:
        set_script_prefix(
            '/' if settings.FORCE_SCRIPT_NAME is None else settings.FORCE_SCRIPT_NAME
        )
    apps.populate(settings.INSTALLED_APPS) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:19,代碼來源:__init__.py

示例6: handle

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import INSTALLED_APPS [as 別名]
def handle(self, *args, **options):
        self.sync_tenant = options.get('tenant')
        self.sync_public = options.get('shared')
        self.schema_name = options.get('schema_name')
        self.executor = options.get('executor')
        self.installed_apps = settings.INSTALLED_APPS
        self.args = args
        self.options = options

        if self.schema_name:
            if self.sync_public:
                raise CommandError("schema should only be used with the --tenant switch.")
            elif self.schema_name == get_public_schema_name():
                self.sync_public = True
            else:
                self.sync_tenant = True
        elif not self.sync_public and not self.sync_tenant:
            # no options set, sync both
            self.sync_tenant = True
            self.sync_public = True

        if hasattr(settings, 'TENANT_APPS'):
            self.tenant_apps = settings.TENANT_APPS
        if hasattr(settings, 'SHARED_APPS'):
            self.shared_apps = settings.SHARED_APPS 
開發者ID:django-tenants,項目名稱:django-tenants,代碼行數:27,代碼來源:__init__.py

示例7: test_medias_method_with_grappelli

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import INSTALLED_APPS [as 別名]
def test_medias_method_with_grappelli(self):
        """
        Tests if the right css ile is triggered when grappelli is installed.
        """
        try:
            import grappelli
        except ImportError:
            return
        settings.INSTALLED_APPS += ('grappelli', )
        self.assertIn('grappelli', settings.INSTALLED_APPS)
        admin = BandAdmin(Band, self.site)
        medias = admin.media
        self.assertTrue(len(medias._css) > 0)
        self.assertIn('all', medias._css)
        self.assertTrue(len(medias._css['all']) == 1)
        self.assertIn('grappelli', medias._css['all'][0]) 
開發者ID:omji,項目名稱:django-tabbed-admin,代碼行數:18,代碼來源:tests.py

示例8: check_crequest

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import INSTALLED_APPS [as 別名]
def check_crequest(app_configs=None, **kwargs):
    errors = []
    if 'crequest' not in settings.INSTALLED_APPS:
        errors.append(
            Error('crequest app is missing',
                  hint='Add `crequest` to INSTALLED_APPS',
                  obj='settings',
                  id='ra.E003',
                  )
        )
    if 'crequest.middleware.CrequestMiddleware' not in settings.MIDDLEWARE:
        errors.append(
            Error('crequest middleware is missing',
                  hint='Add "crequest.middleware.CrequestMiddleware" to MIDDLEWARE',
                  obj='settings',
                  id='ra.E003',
                  )
        )
    return errors 
開發者ID:ra-systems,項目名稱:django-ra-erp,代碼行數:21,代碼來源:checks.py

示例9: main

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import INSTALLED_APPS [as 別名]
def main():
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "yawn.settings.debug")

    # check if yawn is in installed apps, and bail if it is not
    if 'yawn' not in settings.INSTALLED_APPS:
        print("Please check your DJANGO_SETTINGS_MODULE environment variable.\n"
              "Make sure 'yawn' is in your INSTALLED_APPS.\n"
              "Generally, your settings file should start with 'from yawn.settings.base import *'")
        sys.exit(1)

    print('YAWN workflow management tool')
    if os.environ['DJANGO_SETTINGS_MODULE'] == 'yawn.settings.debug':
        print('  Running in DEBUG mode')

    # run the django manage.py command line
    execute_from_command_line(sys.argv) 
開發者ID:aclowes,項目名稱:yawn,代碼行數:18,代碼來源:manage.py

示例10: get

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import INSTALLED_APPS [as 別名]
def get(self, request, *args, **kwargs):
        """
        Django view get function.

        Add items of extra_context, crumbs and grid to context.

        Args:
            request (): Django's request object.
            *args (): request args.
            **kwargs (): request kwargs.

        Returns:
            response: render to response with context.
        """
        context = self.get_context_data(**kwargs)
        context.update(self.extra_context)
        context['crumbs'] = self.get_crumbs()
        context['title'] = self.title
        context['suit'] = 'suit' in settings.INSTALLED_APPS
        if context.get('dashboard_grid', None) is None and self.grid:
            context['dashboard_grid'] = self.grid
        return self.render_to_response(context) 
開發者ID:pawamoy,項目名稱:django-suit-dashboard,代碼行數:24,代碼來源:views.py

示例11: collect_plugins_in_apps

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import INSTALLED_APPS [as 別名]
def collect_plugins_in_apps(module_name: str, module_attr: str) -> Dict[str, Any]:
    """
    Searches for [module_name].py in each app. If there is such module and it has
    [module_attr] attribute in it then add it to the resulting dictionary with key = application name.

    This way we can provide a pluggable architecture for various subsystems.
    For example:
        Documents app searches for "python_coded_fields.py" in each available app.
        It takes PYTHON_CODED_FIELDS list from each found module and puts fields from it in the
        big field registry.
    """
    res = dict()
    custom_apps = [i for i in settings.INSTALLED_APPS if i.startswith('apps.')]
    for app_name in custom_apps:
        module_str = '{0}.{1}'.format(app_name, module_name)
        try:
            app_module = importlib.import_module(module_str)
            if hasattr(app_module, module_attr):
                plugin = getattr(app_module, module_attr)
                res[app_name] = plugin
        except ImportError:
            continue

    return res 
開發者ID:LexPredict,項目名稱:lexpredict-contraxsuite,代碼行數:26,代碼來源:plugins.py

示例12: handle

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import INSTALLED_APPS [as 別名]
def handle(self, *args, **options):

        # 1. remove migration files
        custom_apps = [i.replace('apps.', '') for i in settings.INSTALLED_APPS if
                       i.startswith('apps.')]
        for app_name in custom_apps:
            app_migrations_path = os.path.join(settings.PROJECT_DIR, f'apps/{app_name}/migrations')
            shutil.rmtree(app_migrations_path, ignore_errors=True)

        # drop migrations table
        with connection.cursor() as cursor:
            cursor.execute('DROP TABLE django_migrations;')

        # re-create migration files
        call_command('makemigrations', 'common')
        call_command('makemigrations')

        # re-fill migrations
        call_command('migrate', '--fake') 
開發者ID:LexPredict,項目名稱:lexpredict-contraxsuite,代碼行數:21,代碼來源:force_reinitiate_migrations.py

示例13: setup_dropdown

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import INSTALLED_APPS [as 別名]
def setup_dropdown(context):
    if not SETUP_DROPDOWN:
        for app_name in settings.INSTALLED_APPS:
            app_shortname = app_name.rsplit('.', 1)[-1]
            try:
                url_module = import_module('{}.urls'.format(app_name))
            except ImportError:
                # TODO: ModuleNotFoundError for python >= 3.6
                continue
            setup_menu_cfg = getattr(url_module, 'setup_menu_cfg', None)
            if not setup_menu_cfg:
                logger.info('App %s w/o setup menu config', app_name)
                continue
            section_cfg = {'app_shortname': app_shortname,
                           'title': setup_menu_cfg.get('title', None) or app_shortname.title(),
                           'link_list': [],
                           'weight': setup_menu_cfg.get('weight', 1000)}
            for url_name, anchor_text in setup_menu_cfg['items']:
                section_cfg['link_list'].append((reverse('{}:{}'.format(app_shortname, url_name)),
                                                 anchor_text))
            SETUP_DROPDOWN.append(section_cfg)
        SETUP_DROPDOWN.sort(key=lambda d: (d['weight'], d['title']))
    context["active"] = context.get("setup", False)
    context["section_list"] = SETUP_DROPDOWN
    return context 
開發者ID:zentralopensource,項目名稱:zentral,代碼行數:27,代碼來源:base_extras.py

示例14: get_app_template_dir

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import INSTALLED_APPS [as 別名]
def get_app_template_dir(app_name):
    """
    Get the template directory for an application

    We do not use django.db.models.get_app, because this will fail if an
    app does not have any models.

    Returns a full path, or None if the app was not found.
    """
    if app_name in _cache:
        return _cache[app_name]
    template_dir = None
    for app in settings.INSTALLED_APPS:
        if app.split('.')[-1] == app_name:
            # Do not hide import errors; these should never happen at this
            # point anyway
            mod = import_module(app)
            template_dir = join(abspath(dirname(mod.__file__)), 'templates')
            break
    _cache[app_name] = template_dir
    return template_dir 
開發者ID:bittner,項目名稱:django-apptemplates,代碼行數:23,代碼來源:__init__.py

示例15: setup

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import INSTALLED_APPS [as 別名]
def setup(set_prefix=True):
    """
    Configure the settings (this happens as a side effect of accessing the
    first setting), configure logging and populate the app registry.
    Set the thread-local urlresolvers script prefix if `set_prefix` is True.
    """
    from django.apps import apps
    from django.conf import settings
    from django.urls import set_script_prefix
    from django.utils.encoding import force_text
    from django.utils.log import configure_logging

    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
    if set_prefix:
        set_script_prefix(
            '/' if settings.FORCE_SCRIPT_NAME is None else force_text(settings.FORCE_SCRIPT_NAME)
        )
    apps.populate(settings.INSTALLED_APPS) 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:20,代碼來源:__init__.py


注:本文中的django.conf.settings.INSTALLED_APPS屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。