当前位置: 首页>>代码示例>>Python>>正文


Python models.get_app方法代码示例

本文整理汇总了Python中django.db.models.get_app方法的典型用法代码示例。如果您正苦于以下问题:Python models.get_app方法的具体用法?Python models.get_app怎么用?Python models.get_app使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.db.models的用法示例。


在下文中一共展示了models.get_app方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: build_suite

# 需要导入模块: from django.db import models [as 别名]
# 或者: from django.db.models import get_app [as 别名]
def build_suite(self, test_labels, extra_tests=None, **kwargs):
        suite = unittest.TestSuite()

        if test_labels:
            for label in test_labels:
                if '.' in label:
                    suite.addTest(build_test(label))
                else:
                    app = get_app(label)
                    suite.addTest(build_suite(app))
        else:
            for app in get_apps():
                suite.addTest(build_suite(app))

        if extra_tests:
            for test in extra_tests:
                suite.addTest(test)

        return reorder_suite(suite, (unittest.TestCase,)) 
开发者ID:znick,项目名称:anytask,代码行数:21,代码来源:simple.py

示例2: custom_sql_for_model

# 需要导入模块: from django.db import models [as 别名]
# 或者: from django.db.models import get_app [as 别名]
def custom_sql_for_model(model, style, connection):
    opts = model._meta
    app_dir = os.path.normpath(os.path.join(os.path.dirname(upath(models.get_app(model._meta.app_label).__file__)), 'sql'))
    output = []

    # Post-creation SQL should come before any initial SQL data is loaded.
    # However, this should not be done for models that are unmanaged or
    # for fields that are part of a parent model (via model inheritance).
    if opts.managed:
        post_sql_fields = [f for f in opts.local_fields if hasattr(f, 'post_create_sql')]
        for f in post_sql_fields:
            output.extend(f.post_create_sql(style, model._meta.db_table))

    # Find custom SQL, if it's available.
    backend_name = connection.settings_dict['ENGINE'].split('.')[-1]
    sql_files = [os.path.join(app_dir, "%s.%s.sql" % (opts.object_name.lower(), backend_name)),
                 os.path.join(app_dir, "%s.sql" % opts.object_name.lower())]
    for sql_file in sql_files:
        if os.path.exists(sql_file):
            with codecs.open(sql_file, 'U', encoding=settings.FILE_CHARSET) as fp:
                # Some backends can't execute more than one SQL statement at a time,
                # so split into separate statements.
                output.extend(_split_statements(fp.read()))
    return output 
开发者ID:blackye,项目名称:luscan-devel,代码行数:26,代码来源:sql.py

示例3: handle

# 需要导入模块: from django.db import models [as 别名]
# 或者: from django.db.models import get_app [as 别名]
def handle(self, *args, **options):
        if not args:
            apps = []
            for model in get_models():
                apps.append(get_app(model._meta.app_label))
        else:
            apps = []
            for arg in args:
                apps.append(get_app(arg))
        for app in apps:
            create_permissions(app, get_models(), int(options.get('verbosity', 0))) 
开发者ID:jp74,项目名称:django-model-publisher,代码行数:13,代码来源:update_permissions.py

示例4: handle

# 需要导入模块: from django.db import models [as 别名]
# 或者: from django.db.models import get_app [as 别名]
def handle(self, *app_labels, **options):
        from django.db import models
        if not app_labels:
            raise CommandError('Enter at least one appname.')
        try:
            app_list = [models.get_app(app_label) for app_label in app_labels]
        except (ImproperlyConfigured, ImportError) as e:
            raise CommandError("%s. Are you sure your INSTALLED_APPS setting is correct?" % e)
        output = []
        for app in app_list:
            app_output = self.handle_app(app, **options)
            if app_output:
                output.append(app_output)
        return '\n'.join(output) 
开发者ID:blackye,项目名称:luscan-devel,代码行数:16,代码来源:base.py

示例5: get_app_models

# 需要导入模块: from django.db import models [as 别名]
# 或者: from django.db.models import get_app [as 别名]
def get_app_models(app_name, include_auto_created=False):
    if VERSION >= (1, 7):
        return apps.get_app_config(app_name).get_models(
            include_auto_created=include_auto_created)
    else:
        return get_models(get_app(app_name),
                          include_auto_created=include_auto_created) 
开发者ID:swisscom,项目名称:cleanerversion,代码行数:9,代码来源:helper.py

示例6: setUp

# 需要导入模块: from django.db import models [as 别名]
# 或者: from django.db.models import get_app [as 别名]
def setUp(self):
        from django.db.models.signals import post_save, post_delete
        try:
            from django.db.models.signals import post_migrate
        except ImportError:  # django <= 1.6
            from django.db.models.signals import post_syncdb as post_migrate

        from django_elasticsearch.models import es_save_callback
        from django_elasticsearch.models import es_delete_callback
        from django_elasticsearch.models import es_syncdb_callback
        try:
            from django.apps import apps
            app = apps.get_app_config('django_elasticsearch')
        except ImportError: # django 1.4
            from django.db.models import get_app
            app = get_app('django_elasticsearch')

        post_save.connect(es_save_callback)
        post_delete.connect(es_delete_callback)
        post_migrate.connect(es_syncdb_callback)
        
        if int(get_version()[2]) >= 6:
            sender = app
        else:
            sender = None
        post_migrate.send(sender=sender,
                          app_config=app,
                          app=app,  # django 1.4
                          created_models=[TestModel,],
                          verbosity=2)

        self.instance = TestModel.objects.create(username=u"1",
                                                 first_name=u"woot",
                                                 last_name=u"foo")
        self.instance.es.do_index() 
开发者ID:liberation,项目名称:django-elasticsearch,代码行数:37,代码来源:test_indexable.py

示例7: update_permissions_after_migration

# 需要导入模块: from django.db import models [as 别名]
# 或者: from django.db.models import get_app [as 别名]
def update_permissions_after_migration(app,**kwargs):
    """
    Update app permission just after every migration.
    This is based on app django_extensions update_permissions management command.
    """
    from django.db.models import get_app, get_models
    from django.contrib.auth.management import create_permissions

    create_permissions(get_app(app), get_models(), 2 if settings.DEBUG else 0) 
开发者ID:mediafactory,项目名称:yats,代码行数:11,代码来源:__init__.py


注:本文中的django.db.models.get_app方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。