當前位置: 首頁>>代碼示例>>Python>>正文


Python fields.IntegerField方法代碼示例

本文整理匯總了Python中django.db.models.fields.IntegerField方法的典型用法代碼示例。如果您正苦於以下問題:Python fields.IntegerField方法的具體用法?Python fields.IntegerField怎麽用?Python fields.IntegerField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.db.models.fields的用法示例。


在下文中一共展示了fields.IntegerField方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_django_field_map

# 需要導入模塊: from django.db.models import fields [as 別名]
# 或者: from django.db.models.fields import IntegerField [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 IntegerField [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 IntegerField [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: __init__

# 需要導入模塊: from django.db.models import fields [as 別名]
# 或者: from django.db.models.fields import IntegerField [as 別名]
def __init__(self, expression, distinct=False, **extra):
        if expression == '*':
            expression = Value(expression)
        super(Count, self).__init__(
            expression, distinct='DISTINCT ' if distinct else '', output_field=IntegerField(), **extra) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:7,代碼來源:aggregates.py

示例5: _ordinal_aggregate_field

# 需要導入模塊: from django.db.models import fields [as 別名]
# 或者: from django.db.models.fields import IntegerField [as 別名]
def _ordinal_aggregate_field(self):
        return IntegerField() 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:4,代碼來源:aggregates.py

示例6: _resolve_output_field

# 需要導入模塊: from django.db.models import fields [as 別名]
# 或者: from django.db.models.fields import IntegerField [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 IntegerField [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: __init__

# 需要導入模塊: from django.db.models import fields [as 別名]
# 或者: from django.db.models.fields import IntegerField [as 別名]
def __init__(self, expression, distinct=False, **extra):
        if expression == '*':
            expression = Star()
        super(Count, self).__init__(
            expression, distinct='DISTINCT ' if distinct else '', output_field=IntegerField(), **extra) 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:7,代碼來源:aggregates.py

示例9: __init__

# 需要導入模塊: from django.db.models import fields [as 別名]
# 或者: from django.db.models.fields import IntegerField [as 別名]
def __init__(self, expression, **extra):
        output_field = extra.pop('output_field', fields.IntegerField())
        super(Length, self).__init__(expression, output_field=output_field, **extra) 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:5,代碼來源:base.py

示例10: overview

# 需要導入模塊: from django.db.models import fields [as 別名]
# 或者: from django.db.models.fields import IntegerField [as 別名]
def overview(request, event_url_name):
    event = get_object_or_404(Event, url_name=event_url_name)

    # permission
    if not event.is_admin(request.user):
        return nopermission(request)

    num_helpers = event.helper_set.count()

    num_coordinators = event.all_coordinators.count()

    num_vegetarians = event.helper_set.filter(vegetarian=True).count()

    num_shift_slots = Shift.objects.filter(job__event=event).aggregate(
        Sum('number'))['number__sum']

    empty_slots_expr = ExpressionWrapper(F('number') - F('num_helpers'),
                                         output_field=fields.IntegerField())
    num_empty_shift_slots = Shift.objects.filter(job__event=event) \
        .annotate(num_helpers=Count('helper')) \
        .annotate(empty_slots=empty_slots_expr) \
        .aggregate(Sum('empty_slots'))['empty_slots__sum']

    total_duration = ExpressionWrapper((F('end') - F('begin')) * F('number'),
                                       output_field=fields.DurationField())
    try:
        hours_total = Shift.objects.filter(job__event=event) \
                           .annotate(duration=total_duration) \
                           .aggregate(Sum('duration'))['duration__sum']
    except (OperationalError, OverflowError):
        hours_total = None
    except Exception as e:
        # handle psycopg2.DataError without importing psycopg2
        # happens on overflow with postgresql
        if 'DataError' in str(e.__class__):
            hours_total = None
        else:
            raise e

    # render
    context = {'event': event,
               'num_helpers': num_helpers,
               'num_coordinators': num_coordinators,
               'num_vegetarians': num_vegetarians,
               'num_shift_slots': num_shift_slots,
               'num_empty_shift_slots': num_empty_shift_slots,
               'hours_total': hours_total}
    return render(request, 'statistic/overview.html', context) 
開發者ID:helfertool,項目名稱:helfertool,代碼行數:50,代碼來源:overview.py


注:本文中的django.db.models.fields.IntegerField方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。