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