當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。