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


Python models.BooleanField方法代碼示例

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


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

示例1: _get_matching_omim

# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import BooleanField [as 別名]
def _get_matching_omim(query, projects):
    """Returns OMIM records that match the given query string"""
    records = Omim.objects.filter(
        Q(phenotype_mim_number__icontains=query) | Q(phenotype_description__icontains=query)
    ).filter(phenotype_mim_number__isnull=False).annotate(
        description_start=ExpressionWrapper(Q(phenotype_description__istartswith=query), output_field=BooleanField()),
        mim_number_start=ExpressionWrapper(Q(phenotype_mim_number__istartswith=query), output_field=BooleanField()),
    ).only('phenotype_mim_number', 'phenotype_description').order_by(
        '-description_start', '-mim_number_start', 'phenotype_description').distinct()[:MAX_RESULTS_PER_CATEGORY]
    result = []
    for record in records:
        result.append({
            'key': record.phenotype_mim_number,
            'title': record.phenotype_description,
            'description': '({})'.format(record.phenotype_mim_number) if record.phenotype_mim_number else None,
        })

    return result 
開發者ID:macarthur-lab,項目名稱:seqr,代碼行數:20,代碼來源:awesomebar_api.py

示例2: _get_matching_hpo_terms

# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import BooleanField [as 別名]
def _get_matching_hpo_terms(query, projects):
    """Returns OMIM records that match the given query string"""
    records = HumanPhenotypeOntology.objects.filter(
        Q(hpo_id__icontains=query) | Q(name__icontains=query)
    ).annotate(
        name_start=ExpressionWrapper(Q(name__istartswith=query), output_field=BooleanField()),
        hpo_id_start=ExpressionWrapper(Q(hpo_id__istartswith=query), output_field=BooleanField()),
    ).only('hpo_id', 'name', 'category_id').order_by(
        '-name_start', '-hpo_id_start', 'name').distinct()[:MAX_RESULTS_PER_CATEGORY]
    result = []
    for record in records:
        result.append({
            'key': record.hpo_id,
            'title': record.name,
            'description': '({})'.format(record.hpo_id),
            'category': record.category_id,
        })

    return result 
開發者ID:macarthur-lab,項目名稱:seqr,代碼行數:21,代碼來源:awesomebar_api.py

示例3: display_for_field

# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import BooleanField [as 別名]
def display_for_field(value, field):
    from xadmin.views.list import EMPTY_CHANGELIST_VALUE

    if field.flatchoices:
        return dict(field.flatchoices).get(value, EMPTY_CHANGELIST_VALUE)
    # NullBooleanField needs special-case null-handling, so it comes
    # before the general null test.
    elif isinstance(field, models.BooleanField) or isinstance(field, models.NullBooleanField):
        return boolean_icon(value)
    elif value is None:
        return EMPTY_CHANGELIST_VALUE
    elif isinstance(field, models.DateTimeField):
        return formats.localize(tz_localtime(value))
    elif isinstance(field, (models.DateField, models.TimeField)):
        return formats.localize(value)
    elif isinstance(field, models.DecimalField):
        return formats.number_format(value, field.decimal_places)
    elif isinstance(field, models.FloatField):
        return formats.number_format(value)
    elif isinstance(field.rel, models.ManyToManyRel):
        return ', '.join([smart_text(obj) for obj in value.all()])
    else:
        return smart_text(value) 
開發者ID:stormsha,項目名稱:StormOnline,代碼行數:25,代碼來源:util.py

示例4: display_for_field

# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import BooleanField [as 別名]
def display_for_field(value, field):
    from django.contrib.admin.templatetags.admin_list import _boolean_icon
    from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE

    if field.flatchoices:
        return dict(field.flatchoices).get(value, EMPTY_CHANGELIST_VALUE)
    # NullBooleanField needs special-case null-handling, so it comes
    # before the general null test.
    elif isinstance(field, models.BooleanField) or isinstance(field, models.NullBooleanField):
        return _boolean_icon(value)
    elif value is None:
        return EMPTY_CHANGELIST_VALUE
    elif isinstance(field, models.DateTimeField):
        return formats.localize(timezone.template_localtime(value))
    elif isinstance(field, (models.DateField, models.TimeField)):
        return formats.localize(value)
    elif isinstance(field, models.DecimalField):
        return formats.number_format(value, field.decimal_places)
    elif isinstance(field, models.FloatField):
        return formats.number_format(value)
    elif isinstance(field, models.FileField) and value:
        return format_html('<a href="{}">{}</a>', value.url, value)
    else:
        return smart_text(value) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:26,代碼來源:utils.py

示例5: display_for_field

# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import BooleanField [as 別名]
def display_for_field(value, field, empty_value_display):
    from django.contrib.admin.templatetags.admin_list import _boolean_icon

    if getattr(field, 'flatchoices', None):
        return dict(field.flatchoices).get(value, empty_value_display)
    # NullBooleanField needs special-case null-handling, so it comes
    # before the general null test.
    elif isinstance(field, (models.BooleanField, models.NullBooleanField)):
        return _boolean_icon(value)
    elif value is None:
        return empty_value_display
    elif isinstance(field, models.DateTimeField):
        return formats.localize(timezone.template_localtime(value))
    elif isinstance(field, (models.DateField, models.TimeField)):
        return formats.localize(value)
    elif isinstance(field, models.DecimalField):
        return formats.number_format(value, field.decimal_places)
    elif isinstance(field, (models.IntegerField, models.FloatField)):
        return formats.number_format(value)
    elif isinstance(field, models.FileField) and value:
        return format_html('<a href="{}">{}</a>', value.url, value)
    else:
        return display_for_value(value, empty_value_display) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:25,代碼來源:utils.py

示例6: get_for_site

# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import BooleanField [as 別名]
def get_for_site(cls, handle, site, fall_back_to_default_site_menus=False):
        """Return a FlatMenu instance with a matching ``handle`` for the
        provided ``site``, or for the default site (if suitable). If no
        match is found, returns None."""
        queryset = cls.objects.filter(handle__exact=handle)

        site_q = Q(site=site)
        if fall_back_to_default_site_menus:
            site_q |= Q(site__is_default_site=True)
        queryset = queryset.filter(site_q)

        # return the best match or None
        return queryset.annotate(matched_provided_site=Case(
            When(site_id=site.id, then=1), default=0,
            output_field=BooleanField()
        )).order_by('-matched_provided_site').first() 
開發者ID:rkhleics,項目名稱:wagtailmenus,代碼行數:18,代碼來源:menus.py

示例7: get_queryset

# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import BooleanField [as 別名]
def get_queryset(self):
        try:
            validity_period = SiteConfiguration.get_solo().confirmation_validity_period
        except DatabaseError:
            from datetime import timedelta
            validity_period = timedelta(weeks=42)
        validity_start = timezone.now() - validity_period
        return super().get_queryset().annotate(deleted=Case(
            When(deleted_on__isnull=True, then=False),
            default=True,
            output_field=BooleanField()
        )).annotate(confirmed=Case(
            When(confirmed_on__isnull=True, then=False),
            When(confirmed_on__lt=validity_start, then=False),
            default=True,
            output_field=BooleanField()
        )).annotate(checked=Case(
            When(checked_on__isnull=True, then=False),
            # When(checked_on__lt=validity_start, then=False),  # Temporarily disabled.
            default=True,
            output_field=BooleanField()
        )).select_related() 
開發者ID:tejoesperanto,項目名稱:pasportaservo,代碼行數:24,代碼來源:managers.py

示例8: display_for_field

# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import BooleanField [as 別名]
def display_for_field(value, field):
    from xadmin.views.list import EMPTY_CHANGELIST_VALUE

    if field.flatchoices:
        return dict(field.flatchoices).get(value, EMPTY_CHANGELIST_VALUE)
    # NullBooleanField needs special-case null-handling, so it comes
    # before the general null test.
    elif isinstance(field, models.BooleanField) or isinstance(field, models.NullBooleanField):
        return boolean_icon(value)
    elif value is None:
        return EMPTY_CHANGELIST_VALUE
    elif isinstance(field, models.DateTimeField):
        return formats.localize(tz_localtime(value))
    elif isinstance(field, (models.DateField, models.TimeField)):
        return formats.localize(value)
    elif isinstance(field, models.DecimalField):
        return formats.number_format(value, field.decimal_places)
    elif isinstance(field, models.FloatField):
        return formats.number_format(value)
    elif isinstance(field.remote_field, models.ManyToManyRel):
        return ', '.join([smart_text(obj) for obj in value.all()])
    else:
        return smart_text(value) 
開發者ID:Superbsco,項目名稱:weibo-analysis-system,代碼行數:25,代碼來源:util.py

示例9: display_for_field

# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import BooleanField [as 別名]
def display_for_field(value, field, empty_value_display):
    from django.contrib.admin.templatetags.admin_list import _boolean_icon

    if getattr(field, 'flatchoices', None):
        return dict(field.flatchoices).get(value, empty_value_display)
    # BooleanField needs special-case null-handling, so it comes before the
    # general null test.
    elif isinstance(field, models.BooleanField):
        return _boolean_icon(value)
    elif value is None:
        return empty_value_display
    elif isinstance(field, models.DateTimeField):
        return formats.localize(timezone.template_localtime(value))
    elif isinstance(field, (models.DateField, models.TimeField)):
        return formats.localize(value)
    elif isinstance(field, models.DecimalField):
        return formats.number_format(value, field.decimal_places)
    elif isinstance(field, (models.IntegerField, models.FloatField)):
        return formats.number_format(value)
    elif isinstance(field, models.FileField) and value:
        return format_html('<a href="{}">{}</a>', value.url, value)
    else:
        return display_for_value(value, empty_value_display) 
開發者ID:PacktPublishing,項目名稱:Hands-On-Application-Development-with-PyCharm,代碼行數:25,代碼來源:utils.py

示例10: display_for_field

# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import BooleanField [as 別名]
def display_for_field(value, field, empty_value_display):
    from django.contrib.admin.templatetags.admin_list import _boolean_icon

    if getattr(field, 'flatchoices', None):
        return dict(field.flatchoices).get(value, empty_value_display)
    # NullBooleanField needs special-case null-handling, so it comes
    # before the general null test.
    elif isinstance(field, models.BooleanField) or isinstance(field, models.NullBooleanField):
        return _boolean_icon(value)
    elif value is None:
        return empty_value_display
    elif isinstance(field, models.DateTimeField):
        return formats.localize(timezone.template_localtime(value))
    elif isinstance(field, (models.DateField, models.TimeField)):
        return formats.localize(value)
    elif isinstance(field, models.DecimalField):
        return formats.number_format(value, field.decimal_places)
    elif isinstance(field, (models.IntegerField, models.FloatField)):
        return formats.number_format(value)
    elif isinstance(field, models.FileField) and value:
        return format_html('<a href="{}">{}</a>', value.url, value)
    else:
        return display_for_value(value, empty_value_display) 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:25,代碼來源:utils.py

示例11: display_for_field

# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import BooleanField [as 別名]
def display_for_field(value, field, empty_value_display):
    from django.contrib.admin.templatetags.admin_list import _boolean_icon

    if field.flatchoices:
        return dict(field.flatchoices).get(value, empty_value_display)
    # NullBooleanField needs special-case null-handling, so it comes
    # before the general null test.
    elif isinstance(field, models.BooleanField) or isinstance(field, models.NullBooleanField):
        return _boolean_icon(value)
    elif value is None:
        return empty_value_display
    elif isinstance(field, models.DateTimeField):
        return formats.localize(timezone.template_localtime(value))
    elif isinstance(field, (models.DateField, models.TimeField)):
        return formats.localize(value)
    elif isinstance(field, models.DecimalField):
        return formats.number_format(value, field.decimal_places)
    elif isinstance(field, (models.IntegerField, models.FloatField)):
        return formats.number_format(value)
    elif isinstance(field, models.FileField) and value:
        return format_html('<a href="{}">{}</a>', value.url, value)
    else:
        return smart_text(value) 
開發者ID:drexly,項目名稱:openhgsenti,代碼行數:25,代碼來源:utils.py

示例12: get_queryset

# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import BooleanField [as 別名]
def get_queryset(self):
        today = timezone.localdate()
        return super() \
            .get_queryset() \
            .annotate(attendees_count=models.Count('attendee', distinct=True)) \
            .annotate(last_date=models.Max('eventdate__date')) \
            .annotate(activity_proposal_is_open=models.Case(
                models.When(models.Q(limit_proposal_date__gte=today), then=True),
                default=False,
                output_field=models.BooleanField()
            )) \
            .annotate(registration_is_open=models.Case(
                models.When(models.Q(last_date__gte=today), then=True),
                default=False,
                output_field=models.BooleanField()
            )) 
開發者ID:eventoL,項目名稱:eventoL,代碼行數:18,代碼來源:models.py

示例13: display_for_field

# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import BooleanField [as 別名]
def display_for_field(value, field):
    from xadmin.views.list import EMPTY_CHANGELIST_VALUE

    if field.flatchoices:
        return dict(field.flatchoices).get(value, EMPTY_CHANGELIST_VALUE)
    # NullBooleanField needs special-case null-handling, so it comes
    # before the general null test.
    elif isinstance(field, models.BooleanField) or isinstance(field, models.NullBooleanField):
        return boolean_icon(value)
    elif value is None:
        return EMPTY_CHANGELIST_VALUE
    elif isinstance(field, models.DateTimeField):
        return formats.localize(tz_localtime(value))
    elif isinstance(field, (models.DateField, models.TimeField)):
        return formats.localize(value)
    elif isinstance(field, models.DecimalField):
        return formats.number_format(value, field.decimal_places)
    elif isinstance(field, models.FloatField):
        return formats.number_format(value)
    elif isinstance(field, models.FileField) and value:
        return format_html('<a href="{}">{}</a>', value.url, value)
    else:
        return smart_text(value) 
開發者ID:madre,項目名稱:devops,代碼行數:25,代碼來源:util.py

示例14: document_field

# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import BooleanField [as 別名]
def document_field(field):
    """
    The default ``field_factory`` method for converting Django field instances to ``elasticsearch_dsl.Field`` instances.
    Auto-created fields (primary keys, for example) and one-to-many fields (reverse FK relationships) are skipped.
    """
    if field.auto_created or field.one_to_many:
        return None
    if field.many_to_many:
        return RawMultiString
    defaults = {
        models.DateField: dsl.Date(),
        models.DateTimeField: dsl.Date(),
        models.IntegerField: dsl.Long(),
        models.PositiveIntegerField: dsl.Long(),
        models.BooleanField: dsl.Boolean(),
        models.NullBooleanField: dsl.Boolean(),
        models.SlugField: dsl.String(index='not_analyzed'),
        models.DecimalField: dsl.Double(),
        models.FloatField: dsl.Float(),
    }
    return defaults.get(field.__class__, RawString) 
開發者ID:imsweb,項目名稱:django-seeker,代碼行數:23,代碼來源:mapping.py

示例15: children

# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import BooleanField [as 別名]
def children(self):
        user_ordering = self.SITES_ORDERING[self.sites_ordering]['ordering']
        pages = WagtailSitePage.objects.live().filter(Q(path__startswith=self.path) | Q(in_cooperation_with=self))

        # When ordering by `path`, the collaborations would either all be listed first or last
        # depending on whether the collaborator(s) page(s) was created before or after this page.
        # Adding an overwrite here so collaborations always appear last.
        if self.sites_ordering == self.SITES_ORDERING_PATH:
            pages = pages.annotate(
                is_own=Case(
                    When(path__startswith=self.path, then=Value(True)),
                    default_value=Value(False),
                    output_field=models.BooleanField(),
                )
            ).order_by('is_own', *user_ordering)

        # When ordering alphabetically or by creation date,
        # own sites and collaboration sites will be sorted together.
        else:
            pages = pages.order_by(*user_ordering)

        return pages 
開發者ID:springload,項目名稱:madewithwagtail,代碼行數:24,代碼來源:models.py


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