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