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


Python fields.TextField方法代码示例

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


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

示例1: get_django_field_map

# 需要导入模块: from django.db.models import fields [as 别名]
# 或者: from django.db.models.fields import TextField [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: build_schema_from_model

# 需要导入模块: from django.db.models import fields [as 别名]
# 或者: from django.db.models.fields import TextField [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

示例3: application_details

# 需要导入模块: from django.db.models import fields [as 别名]
# 或者: from django.db.models.fields import TextField [as 别名]
def application_details(application):
    all_fields = application._meta.fields  # pylint:disable=protected-access
    text_fields = [
        (field, getattr(application, field.name))
        for field in all_fields
        if isinstance(field, TextField)
    ]

    familiarities = []
    lead = 'familiarity_'
    for field in (f for f in all_fields if f.name.startswith(lead)):
        if field.name == 'familiarity_sr':
            short_label = 'self-rescue'
        else:
            short_label = field.name[len(lead) :].replace('_', ' ')
        response = getattr(application, 'get_' + field.name + '_display')()
        familiarities.append((short_label, response))

    return {'familiarities': familiarities, 'text_fields': text_fields} 
开发者ID:DavidCain,项目名称:mitoc-trips,代码行数:21,代码来源:application_tags.py

示例4: get_comparison_class

# 需要导入模块: from django.db.models import fields [as 别名]
# 或者: from django.db.models.fields import TextField [as 别名]
def get_comparison_class(self):
        # Hide fields with hidden widget
        widget_override = self.widget_overrides().get(self.field_name, None)
        if widget_override and widget_override.is_hidden:
            return

        try:
            field = self.db_field

            if field.choices:
                return compare.ChoiceFieldComparison

            if field.is_relation:
                if isinstance(field, TaggableManager):
                    return compare.TagsFieldComparison
                elif field.many_to_many:
                    return compare.M2MFieldComparison

                return compare.ForeignObjectComparison

            if isinstance(field, RichTextField):
                return compare.RichTextFieldComparison

            if isinstance(field, (CharField, TextField)):
                return compare.TextFieldComparison

        except FieldDoesNotExist:
            pass

        return compare.FieldComparison 
开发者ID:wagtail,项目名称:wagtail,代码行数:32,代码来源:edit_handlers.py

示例5: LeaderApplicationForm

# 需要导入模块: from django.db.models import fields [as 别名]
# 或者: from django.db.models.fields import TextField [as 别名]
def LeaderApplicationForm(*args, **kwargs):
    """ Factory form for applying to be a leader in any activity. """
    activity = kwargs.pop('activity')

    class DynamicActivityForm(DjangularRequiredModelForm):
        class Meta:
            exclude = ['archived', 'year', 'participant', 'previous_rating']
            model = models.LeaderApplication.model_from_activity(activity)
            widgets = {
                field.name: forms.Textarea(attrs={'rows': 4})
                for field in model._meta.fields  # pylint: disable=protected-access
                if isinstance(field, TextField)
            }

        def clean(self):
            cleaned_data = super().clean()
            if not models.LeaderApplication.accepting_applications(activity):
                raise ValidationError("Not currently accepting applications!")
            return cleaned_data

        def __init__(self, *args, **kwargs):
            # TODO: Errors on args, where args is a single tuple of the view
            # super().__init__(*args, **kwargs)
            super().__init__(**kwargs)

    return DynamicActivityForm(*args, **kwargs) 
开发者ID:DavidCain,项目名称:mitoc-trips,代码行数:28,代码来源:forms.py


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