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


Python options.Options方法代码示例

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


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

示例1: copy_managers

# 需要导入模块: from django.db.models import options [as 别名]
# 或者: from django.db.models.options import Options [as 别名]
def copy_managers(cls, base_managers):
        # This is in-place sorting of an Options attribute, but that's fine.
        base_managers.sort()
        for _, mgr_name, manager in base_managers:  # NOQA (redefinition of _)
            val = getattr(cls, mgr_name, None)
            if not val or val is manager:
                new_manager = manager._copy_to_model(cls)
                cls.add_to_class(mgr_name, new_manager) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:10,代码来源:base.py

示例2: fields

# 需要导入模块: from django.db.models import options [as 别名]
# 或者: from django.db.models.options import Options [as 别名]
def fields(self):
        return Options.fields.func(self) 
开发者ID:OpenAgricultureFoundation,项目名称:gro-api,代码行数:4,代码来源:models.py

示例3: concrete_fields

# 需要导入模块: from django.db.models import options [as 别名]
# 或者: from django.db.models.options import Options [as 别名]
def concrete_fields(self):
        return Options.concrete_fields.func(self) 
开发者ID:OpenAgricultureFoundation,项目名称:gro-api,代码行数:4,代码来源:models.py

示例4: local_concrete_fields

# 需要导入模块: from django.db.models import options [as 别名]
# 或者: from django.db.models.options import Options [as 别名]
def local_concrete_fields(self):
        return Options.local_concrete_fields.func(self) 
开发者ID:OpenAgricultureFoundation,项目名称:gro-api,代码行数:4,代码来源:models.py

示例5: many_to_many

# 需要导入模块: from django.db.models import options [as 别名]
# 或者: from django.db.models.options import Options [as 别名]
def many_to_many(self):
        return Options.many_to_many.func(self) 
开发者ID:OpenAgricultureFoundation,项目名称:gro-api,代码行数:4,代码来源:models.py

示例6: related_objects

# 需要导入模块: from django.db.models import options [as 别名]
# 或者: from django.db.models.options import Options [as 别名]
def related_objects(self):
        return Options.related_objects.func(self) 
开发者ID:OpenAgricultureFoundation,项目名称:gro-api,代码行数:4,代码来源:models.py

示例7: fields_map

# 需要导入模块: from django.db.models import options [as 别名]
# 或者: from django.db.models.options import Options [as 别名]
def fields_map(self):
        return Options.fields_map.func(self) 
开发者ID:OpenAgricultureFoundation,项目名称:gro-api,代码行数:4,代码来源:models.py

示例8: copy_managers

# 需要导入模块: from django.db.models import options [as 别名]
# 或者: from django.db.models.options import Options [as 别名]
def copy_managers(cls, base_managers):
        # This is in-place sorting of an Options attribute, but that's fine.
        base_managers.sort()
        for _, mgr_name, manager in base_managers:
            val = getattr(cls, mgr_name, None)
            if not val or val is manager:
                new_manager = manager._copy_to_model(cls)
                cls.add_to_class(mgr_name, new_manager) 
开发者ID:blackye,项目名称:luscan-devel,代码行数:10,代码来源:base.py

示例9: _meta

# 需要导入模块: from django.db.models import options [as 别名]
# 或者: from django.db.models.options import Options [as 别名]
def _meta(self):
        if hasattr(self.Meta, 'unique_together'):
            raise NotImplementedError('unique_together property not supported by neomodel')

        opts = Options(self.Meta, app_label=self.Meta.app_label)
        opts.contribute_to_class(self.__class__, self.__class__.__name__)

        for key, prop in self.__all_properties__:
            opts.add_field(DjangoField(prop, key), getattr(prop, 'private', False))

        return opts 
开发者ID:neo4j-contrib,项目名称:django-neomodel,代码行数:13,代码来源:__init__.py

示例10: _give_columns_django_field_attributes

# 需要导入模块: from django.db.models import options [as 别名]
# 或者: from django.db.models.options import Options [as 别名]
def _give_columns_django_field_attributes(self):
        """
        Add Django Field attributes to each cqlengine.Column instance.

        So that the Django Options class may interact with it as if it were
        a Django Field.
        """
        methods_to_add = (
            django_field_methods.value_from_object,
            django_field_methods.value_to_string,
            django_field_methods.get_attname,
            django_field_methods.get_cache_name,
            django_field_methods.pre_save,
            django_field_methods.get_prep_value,
            django_field_methods.get_choices,
            django_field_methods.get_choices_default,
            django_field_methods.save_form_data,
            django_field_methods.formfield,
            django_field_methods.get_db_prep_value,
            django_field_methods.get_db_prep_save,
            django_field_methods.db_type_suffix,
            django_field_methods.select_format,
            django_field_methods.get_internal_type,
            django_field_methods.get_attname_column,
            django_field_methods.check,
            django_field_methods._check_field_name,
            django_field_methods._check_db_index,
            django_field_methods.deconstruct,
            django_field_methods.run_validators,
            django_field_methods.clean,
            django_field_methods.get_db_converters,
            django_field_methods.get_prep_lookup,
            django_field_methods.get_db_prep_lookup,
            django_field_methods.get_filter_kwargs_for_object,
            django_field_methods.set_attributes_from_name,
            django_field_methods.db_parameters,
            django_field_methods.get_pk_value_on_save,
            django_field_methods.get_col,
        )
        for name, cql_column in six.iteritems(self._defined_columns):
            self._set_column_django_attributes(cql_column=cql_column, name=name)
            for method in methods_to_add:
                try:
                    method_name = method.func_name
                except AttributeError:
                    # python 3
                    method_name = method.__name__

                new_method = six.create_bound_method(method, cql_column)
                setattr(cql_column, method_name, new_method) 
开发者ID:r4fek,项目名称:django-cassandra-engine,代码行数:52,代码来源:__init__.py

示例11: _add_django_meta_and_register_model

# 需要导入模块: from django.db.models import options [as 别名]
# 或者: from django.db.models.options import Options [as 别名]
def _add_django_meta_and_register_model(cls, klass, attrs, name):
        # Create the class.
        module = attrs.get('__module__')
        if not module:
            return klass

        new_class = klass
        attr_meta = attrs.pop('Meta', None)
        abstract = getattr(attr_meta, 'abstract', False)
        if not attr_meta:
            meta = getattr(new_class, 'Meta', None)
        else:
            meta = attr_meta

        if meta:
            meta.managed = False

        app_label = None

        # Look for an application configuration to attach the model to.
        app_config = apps.get_containing_app_config(module)

        if getattr(meta, 'app_label', None) is None:
            if app_config is None:
                if not abstract:
                    raise RuntimeError(
                        "Model class %s.%s doesn't declare an explicit "
                        "app_label and isn't in an application in "
                        "INSTALLED_APPS." % (module, name)
                    )

            else:
                app_label = app_config.label

        # Add _meta/Options attribute to the model
        new_class.add_to_class(
            '_meta', DjangoCassandraOptions(meta, app_label, cls=new_class))
        # Add manager to the model
        for manager_attr in _django_manager_attr_names:
            new_class.add_to_class(manager_attr, new_class.objects)
        # Register the model
        new_class._meta.apps.register_model(new_class._meta.app_label, new_class)
        return new_class 
开发者ID:r4fek,项目名称:django-cassandra-engine,代码行数:45,代码来源:__init__.py


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