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


Python Field.__init__方法代码示例

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


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

示例1: __init__

# 需要导入模块: from django.db.models.fields.related import Field [as 别名]
# 或者: from django.db.models.fields.related.Field import __init__ [as 别名]
    def __init__(self, to, **kwargs):
        kwargs['verbose_name'] = kwargs.get('verbose_name', None)
        kwargs['rel'] = GenericRel(to,
                            related_name=kwargs.pop('related_name', None),
                            limit_choices_to=kwargs.pop('limit_choices_to', None),
                            symmetrical=kwargs.pop('symmetrical', True))

        # Override content-type/object-id field names on the related class
        self.object_id_field_name = kwargs.pop("object_id_field", "object_id")
        self.content_type_field_name = kwargs.pop("content_type_field", "content_type")

        kwargs['blank'] = True
        kwargs['editable'] = False
        kwargs['serialize'] = False
        Field.__init__(self, **kwargs)
开发者ID:taylanpince,项目名称:orangeblog,代码行数:17,代码来源:generic.py

示例2: __init__

# 需要导入模块: from django.db.models.fields.related import Field [as 别名]
# 或者: from django.db.models.fields.related.Field import __init__ [as 别名]
    def __init__(self, to, **kwargs):
        kwargs["verbose_name"] = kwargs.get("verbose_name", None)
        kwargs["rel"] = GenericRel(
            to,
            related_name=kwargs.pop("related_name", None),
            limit_choices_to=kwargs.pop("limit_choices_to", None),
            symmetrical=kwargs.pop("symmetrical", True),
        )

        # Override content-type/object-id field names on the related class
        self.object_id_field_name = kwargs.pop("object_id_field", "object_id")
        self.content_type_field_name = kwargs.pop("content_type_field", "content_type")

        kwargs["blank"] = True
        kwargs["editable"] = False
        kwargs["serialize"] = False
        Field.__init__(self, **kwargs)
开发者ID:novdev,项目名称:django,代码行数:19,代码来源:generic.py

示例3: __init__

# 需要导入模块: from django.db.models.fields.related import Field [as 别名]
# 或者: from django.db.models.fields.related.Field import __init__ [as 别名]
    def __init__(self, **kwargs):
        if self.__class__ == RelatedMediaField:
            raise ValueError, 'RelatedMediaField cannot be used directly.  You must subclass it.'

        kwargs['rel'] = RelatedMediaRel(self.to,
                            related_name=kwargs.pop('related_name', None),
                            limit_choices_to=kwargs.pop('limit_choices_to', None),
                            symmetrical=kwargs.pop('symmetrical', True))

        # We don't create any tables, but use generic relations through MediaRelation
        self.creates_table = False

        self.object_id_field_name = 'object_id'

        kwargs['blank'] = True
        kwargs['editable'] = False
        kwargs['serialize'] = False
        Field.__init__(self, **kwargs)
开发者ID:joaquinquintas,项目名称:trade,代码行数:20,代码来源:related.py

示例4: __init__

# 需要导入模块: from django.db.models.fields.related import Field [as 别名]
# 或者: from django.db.models.fields.related.Field import __init__ [as 别名]
    def __init__(self, to, **kwargs):
        # copied from parent only to change rel type to OneToManyRel
        try:
            assert not to._meta.abstract, "%s cannot define a relation with abstract class %s" % (self.__class__.__name__, to._meta.object_name)
        except AttributeError: # to._meta doesn't exist, so it must be RECURSIVE_RELATIONSHIP_CONSTANT
            assert isinstance(to, basestring), "%s(%r) is invalid. First parameter to ManyToManyField must be either a model, a model name, or the string %r" % (self.__class__.__name__, to, RECURSIVE_RELATIONSHIP_CONSTANT)

        kwargs['verbose_name'] = kwargs.get('verbose_name', None)
        kwargs['rel'] = OneToManyRel(to,
            related_name=kwargs.pop('related_name', None),
            limit_choices_to=kwargs.pop('limit_choices_to', None),
            symmetrical=kwargs.pop('symmetrical', to==RECURSIVE_RELATIONSHIP_CONSTANT),
            through=kwargs.pop('through', None))

        self.db_table = kwargs.pop('db_table', None)
        if kwargs['rel'].through is not None:
            assert self.db_table is None, "Cannot specify a db_table if an intermediary model is used."

        Field.__init__(self, **kwargs)

        msg = _('Hold down "Control", or "Command" on a Mac, to select more than one.')
        self.help_text = string_concat(self.help_text, ' ', msg)
开发者ID:pombredanne,项目名称:django-remoteforeignkey,代码行数:24,代码来源:models.py


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