当前位置: 首页>>代码示例>>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;未经允许,请勿转载。