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


Python fields.Field类代码示例

本文整理汇总了Python中fields.Field的典型用法代码示例。如果您正苦于以下问题:Python Field类的具体用法?Python Field怎么用?Python Field使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __init__

    def __init__(
        self,
        queryset,
        empty_label=u"---------",
        cache_choices=False,
        required=True,
        widget=None,
        label=None,
        initial=None,
        help_text=None,
        to_field_name=None,
        *args,
        **kwargs
    ):
        if required and (initial is not None):
            self.empty_label = None
        else:
            self.empty_label = empty_label
        self.cache_choices = cache_choices

        # Call Field instead of ChoiceField __init__() because we don't need
        # ChoiceField.__init__().
        Field.__init__(self, required, widget, label, initial, help_text, *args, **kwargs)
        self.queryset = queryset
        self.choice_cache = None
        self.to_field_name = to_field_name
开发者ID:Ryati,项目名称:django,代码行数:26,代码来源:models.py

示例2: __init__

 def __init__(self):
     Field.__init__(self)
     scriptList.register(self)
     from kivy.app import App
     def inner(*args):
         self.stack = App.get_running_app().root.ids['deck'].ids['stack']
     from kivy.clock import Clock
     Clock.schedule_once(inner,1)
开发者ID:opqopq,项目名称:BoardGameMaker,代码行数:8,代码来源:scripts.py

示例3: clean

 def clean(self, value):
     Field.clean(self, value)
     if value in EMPTY_VALUES:
         return None
     try:
         value = self.queryset.get(pk=value)
     except self.queryset.model.DoesNotExist:
         raise ValidationError(self.error_messages['invalid_choice'])
     return value
开发者ID:taylanpince,项目名称:orangeblog,代码行数:9,代码来源:models.py

示例4: clean

 def clean(self, value):
     Field.clean(self, value)
     if value in ('', None):
         return None
     try:
         value = self.queryset.model._default_manager.get(pk=value)
     except self.queryset.model.DoesNotExist:
         raise ValidationError(gettext(u'Select a valid choice. That choice is not one of the available choices.'))
     return value
开发者ID:0xmilk,项目名称:appscale,代码行数:9,代码来源:models.py

示例5: __init__

 def __init__(self, queryset, empty_label=u"---------", cache_choices=False,
         required=True, widget=Select, label=None, initial=None, help_text=None):
     self.queryset = queryset
     self.empty_label = empty_label
     self.cache_choices = cache_choices
     # Call Field instead of ChoiceField __init__() because we don't need
     # ChoiceField.__init__().
     Field.__init__(self, required, widget, label, initial, help_text)
     self.widget.choices = self.choices
开发者ID:0xmilk,项目名称:appscale,代码行数:9,代码来源:models.py

示例6: clean

 def clean(self, value):
     Field.clean(self, value)
     if value in EMPTY_VALUES:
         return None
     if self.to_field_name:
         value = deepcopy(self.queryset).filter(self.to_field_name + ' =',
                                                value).get()
     else:
         value = self.queryset.model.get(value)
     if not value:
         raise ValidationError(self.error_messages['invalid_choice'])
     return value
开发者ID:avastjohn,项目名称:maventy_old,代码行数:12,代码来源:models.py

示例7: validate

 def validate(self, value):
     return Field.validate(self, value)
开发者ID:Ryati,项目名称:django,代码行数:2,代码来源:models.py

示例8: parse_field

def parse_field(name):    
    if isinstance(name, Field) or isinstance(name, FieldSize):
        size = name
    else:
        size = Field.find(name)
    return size
开发者ID:dexX7,项目名称:MasterBuilder,代码行数:6,代码来源:parser.py

示例9: test_inverse

 def test_inverse(self):
     a = Field(7, 23)
     self.assertEqual(a.inverse().value, 10)
     self.assertEqual((a.inverse() * 7).value, 1)
开发者ID:singulared,项目名称:fields,代码行数:4,代码来源:tests.py


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