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


Python fields.DecimalField方法代码示例

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


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

示例1: get_django_field_map

# 需要导入模块: from django.db.models import fields [as 别名]
# 或者: from django.db.models.fields import DecimalField [as 别名]
def get_django_field_map(self):
        from django.db.models import fields as djf
        return [
            (djf.AutoField, PrimaryKeyField),
            (djf.BigIntegerField, BigIntegerField),
            # (djf.BinaryField, BlobField),
            (djf.BooleanField, BooleanField),
            (djf.CharField, CharField),
            (djf.DateTimeField, DateTimeField),  # Extends DateField.
            (djf.DateField, DateField),
            (djf.DecimalField, DecimalField),
            (djf.FilePathField, CharField),
            (djf.FloatField, FloatField),
            (djf.IntegerField, IntegerField),
            (djf.NullBooleanField, partial(BooleanField, null=True)),
            (djf.TextField, TextField),
            (djf.TimeField, TimeField),
            (djf.related.ForeignKey, ForeignKeyField),
        ] 
开发者ID:danielecook,项目名称:Quiver-alfred,代码行数:21,代码来源:djpeewee.py

示例2: __init__

# 需要导入模块: from django.db.models import fields [as 别名]
# 或者: from django.db.models.fields import DecimalField [as 别名]
def __init__(self, field, request, params, model, model_admin, field_path):
        super().__init__(field, request, params, model, model_admin, field_path)

        if not isinstance(field, (DecimalField, IntegerField, FloatField, AutoField)):
            raise TypeError('Class {} is not supported for {}.'.format(type(self.field), self.__class__.__name__))

        self.request = request

        if self.parameter_name is None:
            self.parameter_name = self.field.name

        if self.parameter_name + '_from' in params:
            value = params.pop(self.parameter_name + '_from')
            self.used_parameters[self.parameter_name + '_from'] = value

        if self.parameter_name + '_to' in params:
            value = params.pop(self.parameter_name + '_to')
            self.used_parameters[self.parameter_name + '_to'] = value 
开发者ID:lukasvinclav,项目名称:django-admin-numeric-filter,代码行数:20,代码来源:admin.py

示例3: build_schema_from_model

# 需要导入模块: from django.db.models import fields [as 别名]
# 或者: from django.db.models.fields import DecimalField [as 别名]
def build_schema_from_model(model):
    field_mappings = {
        model_fields.BigIntegerField: "INTEGER",
        model_fields.CharField: "STRING",
        model_fields.DateField: "DATE",
        model_fields.FloatField: "FLOAT",
        model_fields.DecimalField: "NUMERIC",
        model_fields.IntegerField: "INTEGER",
        model_fields.BooleanField: "BOOLEAN",
        model_fields.NullBooleanField: "BOOLEAN",
        model_fields.TextField: "STRING",
        related_fields.ForeignKey: "INTEGER",
        related_fields.OneToOneField: "INTEGER",
    }

    fields = [
        (f.name, field_mappings[type(f)])
        for f in model._meta.fields
        if not f.auto_created
    ]

    return build_schema(*fields) 
开发者ID:ebmdatalab,项目名称:openprescribing,代码行数:24,代码来源:bigquery.py

示例4: _build_search_filter

# 需要导入模块: from django.db.models import fields [as 别名]
# 或者: from django.db.models.fields import DecimalField [as 别名]
def _build_search_filter(cls, field_name):
    if field_name == "bnf_code":
        return _build_search_filter_bnf_code_prefox()

    field = cls._meta.get_field(field_name)
    builder = {
        ForeignKey: _build_search_filter_fk,
        ManyToOneRel: _build_search_filter_rev_fk,
        OneToOneRel: _build_search_filter_rev_fk,
        fields.CharField: _build_search_filter_char,
        fields.DateField: _build_search_filter_date,
        fields.BooleanField: _build_search_filter_boolean,
        fields.DecimalField: _build_search_filter_decimal,
    }[type(field)]
    search_filter = builder(field)
    search_filter["id"] = field_name
    return search_filter 
开发者ID:ebmdatalab,项目名称:openprescribing,代码行数:19,代码来源:build_search_filters.py

示例5: choices

# 需要导入模块: from django.db.models import fields [as 别名]
# 或者: from django.db.models.fields import DecimalField [as 别名]
def choices(self, changelist):
        total = self.q.all().count()

        min_value = self.q.all().aggregate(
            min=Min(self.parameter_name)
        ).get('min', 0)

        if total > 1:
            max_value = self.q.all().aggregate(
                max=Max(self.parameter_name)
            ).get('max', 0)
        else:
            max_value = None

        if isinstance(self.field, (FloatField, DecimalField)):
            decimals = self.MAX_DECIMALS
            step = self.STEP if self.STEP else self._get_min_step(self.MAX_DECIMALS)
        else:
            decimals = 0
            step = self.STEP if self.STEP else 1

        return ({
            'decimals': decimals,
            'step': step,
            'parameter_name': self.parameter_name,
            'request': self.request,
            'min': min_value,
            'max': max_value,
            'value_from': self.used_parameters.get(self.parameter_name + '_from', min_value),
            'value_to': self.used_parameters.get(self.parameter_name + '_to', max_value),
            'form': SliderNumericForm(name=self.parameter_name, data={
                self.parameter_name + '_from': self.used_parameters.get(self.parameter_name + '_from', min_value),
                self.parameter_name + '_to': self.used_parameters.get(self.parameter_name + '_to', max_value),
            })
        }, ) 
开发者ID:lukasvinclav,项目名称:django-admin-numeric-filter,代码行数:37,代码来源:admin.py

示例6: _resolve_output_field

# 需要导入模块: from django.db.models import fields [as 别名]
# 或者: from django.db.models.fields import DecimalField [as 别名]
def _resolve_output_field(self):
        source_field = self.get_source_fields()[0]
        if isinstance(source_field, (IntegerField, DecimalField)):
            return FloatField()
        return super()._resolve_output_field() 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:7,代码来源:aggregates.py

示例7: _resolve_output_field

# 需要导入模块: from django.db.models import fields [as 别名]
# 或者: from django.db.models.fields import DecimalField [as 别名]
def _resolve_output_field(self):
        source_field = self.get_source_fields()[0]
        if isinstance(source_field, (IntegerField, DecimalField)):
            self._output_field = FloatField()
        super(Avg, self)._resolve_output_field() 
开发者ID:Yeah-Kun,项目名称:python,代码行数:7,代码来源:aggregates.py

示例8: _build_lookup_key

# 需要导入模块: from django.db.models import fields [as 别名]
# 或者: from django.db.models.fields import DecimalField [as 别名]
def _build_lookup_key(cls, field_name, operator):
    field = cls._meta.get_field(field_name)
    builder = {
        ForeignKey: _build_lookup_fk,
        ManyToOneRel: _build_lookup_rev_fk,
        OneToOneRel: _build_lookup_rev_fk,
        fields.CharField: _build_lookup_char,
        fields.DateField: _build_lookup_date,
        fields.BooleanField: _build_lookup_boolean,
        fields.DecimalField: _build_lookup_decimal,
    }[type(field)]
    return builder(cls, field_name, operator) 
开发者ID:ebmdatalab,项目名称:openprescribing,代码行数:14,代码来源:build_search_query.py


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