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


Python forms.FloatField方法代码示例

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


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

示例1: get_entry_field

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FloatField [as 别名]
def get_entry_field(self, questionanswer=None, student=None):
        resp_type = self.question.config.get('resp_type', 'float')
        if questionanswer:
            initial = questionanswer.answer.get('data', '')
        else:
            initial = None

        if resp_type == 'int':
            field = forms.IntegerField(required=False, initial=initial)
        else:
            field = forms.FloatField(required=False, initial=initial)

        field.widget.attrs.update({'class': 'numeric-answer'})
        return field 
开发者ID:sfu-fas,项目名称:coursys,代码行数:16,代码来源:text.py

示例2: formfield

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FloatField [as 别名]
def formfield(self, **kwargs):
        defaults = {'widget': django_forms.TextInput(attrs={'class': 'vIntegerField'}),
                    'initial': self.default}
        defaults.update(kwargs)
        return django_forms.FloatField(**defaults)


# ------------------------------------------------------------------------------- 
开发者ID:cyanfish,项目名称:heltour,代码行数:10,代码来源:models.py

示例3: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FloatField [as 别名]
def __init__(self, *args, **kwargs):
        reg = kwargs.pop('registration')
        super(ApproveRegistrationForm, self).__init__(*args, **kwargs)

        workflow = ApproveRegistrationWorkflow(reg)

        self.fields['send_confirm_email'].initial = workflow.default_send_confirm_email
        self.fields['invite_to_slack'].initial = workflow.default_invite_to_slack

        section_list = reg.season.section_list()
        if len(section_list) > 1:
            section_options = [(season.id, season.section.name) for season in section_list]
            self.fields['section'] = forms.ChoiceField(choices=section_options,
                                                       initial=workflow.default_section.id)

        if workflow.is_late:
            self.fields['retroactive_byes'] = forms.IntegerField(initial=workflow.default_byes)
            self.fields['late_join_points'] = forms.FloatField(initial=workflow.default_ljp) 
开发者ID:cyanfish,项目名称:heltour,代码行数:20,代码来源:forms.py

示例4: get_prep_value

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FloatField [as 别名]
def get_prep_value(self, value):
        value = super(FloatField, self).get_prep_value(value)
        if value is None:
            return None
        return float(value) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:7,代码来源:__init__.py

示例5: get_internal_type

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FloatField [as 别名]
def get_internal_type(self):
        return "FloatField" 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:4,代码来源:__init__.py

示例6: formfield

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FloatField [as 别名]
def formfield(self, **kwargs):
        defaults = {'form_class': forms.FloatField}
        defaults.update(kwargs)
        return super(FloatField, self).formfield(**defaults) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:6,代码来源:__init__.py

示例7: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FloatField [as 别名]
def __init__(self, project, *args, **kwargs):
        kwargs.setdefault('label_suffix', '')
        super(SiteBulkEditForm, self).__init__(*args, **kwargs)

        self.fields['sites'] = forms.ModelMultipleChoiceField(
            widget=forms.CheckboxSelectMultiple,
            queryset=project.sites.all(),
        )

        for attr in project.site_meta_attributes:
            q_type = attr['question_type']
            q_name = attr['question_name']

            if q_type == 'Number':
                field = forms.FloatField()
            elif q_type == 'Date':
                field = forms.DateField()
            elif q_type == 'MCQ':
                options = attr.get('mcq_options') or []
                choices = [o.get('option_text') for o in options]
                choices = [(c, c) for c in choices]
                field = forms.ChoiceField(choices=choices)
            else:
                field = forms.CharField()

            self.fields[q_name] = field 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:28,代码来源:forms.py

示例8: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FloatField [as 别名]
def __init__(self, *args, **kwargs):
        name = kwargs.pop('name')
        super().__init__(*args, **kwargs)

        self.fields[name] = forms.FloatField(label='', required=False,
            widget=forms.NumberInput(attrs={'placeholder': _('Value')})) 
开发者ID:lukasvinclav,项目名称:django-admin-numeric-filter,代码行数:8,代码来源:forms.py

示例9: formfield

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FloatField [as 别名]
def formfield(self, **kwargs):
        defaults = {'form_class': forms.FloatField}
        defaults.update(kwargs)
        return super().formfield(**defaults) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:6,代码来源:__init__.py

示例10: extra_field_to_form_field

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FloatField [as 别名]
def extra_field_to_form_field(field_type):
    if field_type == 'number':
        return forms.FloatField(required=False)
    elif field_type == 'boolean':
        return forms.BooleanField(required=False)
    elif field_type == 'datetime':
        return forms.DateTimeField(required=False)
    elif field_type == 'string':
        return forms.CharField(required=False, widget=forms.Textarea)
    else:
        raise ValueError(
            'Invalid field type {}. Field type must be one of: number, boolean, datetime string'.format(field_type)
        ) 
开发者ID:TOMToolkit,项目名称:tom_base,代码行数:15,代码来源:forms.py

示例11: formfield

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FloatField [as 别名]
def formfield(self, **kwargs):
        return super().formfield(**{
            'form_class': forms.FloatField,
            **kwargs,
        }) 
开发者ID:PacktPublishing,项目名称:Hands-On-Application-Development-with-PyCharm,代码行数:7,代码来源:__init__.py

示例12: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FloatField [as 别名]
def __init__(self, required=True, max_value=None, min_value=None, validators=(), *args,
                 **kwargs):
        self.field = forms.FloatField(
            required=required,
            max_value=max_value,
            min_value=min_value,
            validators=validators,
        )
        super().__init__(*args, **kwargs) 
开发者ID:wagtail,项目名称:wagtail,代码行数:11,代码来源:field_block.py

示例13: _create_datatype_field

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FloatField [as 别名]
def _create_datatype_field(p_type, p_help, lbl):
        """Create a new field depending on the datatype."""
        if p_type == 'integer':
            new_field = forms.IntegerField(
                label=lbl,
                required=False,
                help_text=p_help)

        elif p_type == 'double':
            new_field = forms.FloatField(
                label=lbl,
                required=False,
                help_text=p_help)

        elif p_type == 'string':
            new_field = forms.CharField(
                max_length=STRING_PARAM_MAX_LENGTH,
                strip=True,
                required=False,
                label=lbl,
                help_text=p_help)
        elif p_type == 'boolean':
            new_field = forms.BooleanField(
                required=False,
                label=lbl,
                help_text=p_help)
        else:  # p_type == 'datetime':
            new_field = forms.DateTimeField(
                required=False,
                label=lbl,
                widget=DateTimePickerInput(options=DATE_TIME_WIDGET_OPTIONS),
                help_text=p_help)

        return new_field 
开发者ID:abelardopardo,项目名称:ontask_b,代码行数:36,代码来源:plugin.py

示例14: test_should_float_convert_float

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FloatField [as 别名]
def test_should_float_convert_float():
    assert_conversion(forms.FloatField, Float) 
开发者ID:graphql-python,项目名称:graphene-django,代码行数:4,代码来源:test_converter.py

示例15: get_form_field

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import FloatField [as 别名]
def get_form_field(self, **kwargs):
    """Return a Django form field appropriate for an integer property.

    This defaults to a FloatField instance when using Django 0.97 or
    later.  For 0.96 this defaults to the CharField class.
    """
    defaults = {}
    if hasattr(forms, 'FloatField'):
      defaults['form_class'] = forms.FloatField
    defaults.update(kwargs)
    return super(FloatProperty, self).get_form_field(**defaults) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:13,代码来源:djangoforms.py


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