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


Python humanize.intcomma方法代碼示例

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


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

示例1: shared_static_pages

# 需要導入模塊: from django.contrib.humanize.templatetags import humanize [as 別名]
# 或者: from django.contrib.humanize.templatetags.humanize import intcomma [as 別名]
def shared_static_pages(request, page):
    from django.utils.module_loading import import_string
    from django.contrib.humanize.templatetags.humanize import intcomma
    password_hasher = import_string(settings.PASSWORD_HASHERS[0])()
    password_hash_method = password_hasher.algorithm.upper().replace("_", " ") \
        + " (" + intcomma(password_hasher.iterations) + " iterations)"

    return render(request,
        page + ".html", {
        "base_template": "base.html",
        "SITE_ROOT_URL": request.build_absolute_uri("/"),
        "password_hash_method": password_hash_method,
        # "project_form": ProjectForm(request.user),
        "project_form": None,
    })

# SINGLE SIGN ON 
開發者ID:GovReady,項目名稱:govready-q,代碼行數:19,代碼來源:views.py

示例2: add_metadata

# 需要導入模塊: from django.contrib.humanize.templatetags import humanize [as 別名]
# 或者: from django.contrib.humanize.templatetags.humanize import intcomma [as 別名]
def add_metadata(request, coin_symbol):
    block_hash = get_latest_block_hash(coin_symbol)

    block_overview = get_block_overview(
            block_representation=block_hash,
            coin_symbol=coin_symbol,
            txn_limit=500,
            api_key=BLOCKCYPHER_API_KEY,
            )

    random_tx_hash = choice(block_overview['txids'])

    redir_url = reverse(
            'add_metadata_to_tx',
            kwargs={'coin_symbol': coin_symbol, 'tx_hash': random_tx_hash},
            )

    msg = _('%(cs_display)s transaction %(tx_hash)s from latest block (%(latest_block_num)s) randomly selected' % {
        'cs_display': COIN_SYMBOL_MAPPINGS[coin_symbol]['currency_abbrev'],
        'tx_hash': random_tx_hash,
        'latest_block_num': intcomma(block_overview['height']),
        })

    messages.success(request, msg, extra_tags='safe')
    return HttpResponseRedirect(redir_url) 
開發者ID:blockcypher,項目名稱:explorer,代碼行數:27,代碼來源:views.py

示例3: to_int_comma

# 需要導入模塊: from django.contrib.humanize.templatetags import humanize [as 別名]
# 或者: from django.contrib.humanize.templatetags.humanize import intcomma [as 別名]
def to_int_comma(num):
    return intcomma(int(num)) 
開發者ID:gcallah,項目名稱:indras_net,代碼行數:4,代碼來源:formatting.py

示例4: clean_amount

# 需要導入模塊: from django.contrib.humanize.templatetags import humanize [as 別名]
# 或者: from django.contrib.humanize.templatetags.humanize import intcomma [as 別名]
def clean_amount(self):
        """Validate the provided amount of an asset."""
        amount = round(self.cleaned_data["amount"], self.decimal_places)
        if amount < self.min_amount:
            raise forms.ValidationError(
                _("The minimum amount is: %s")
                % intcomma(round(self.min_amount, self.decimal_places))
            )
        elif amount > self.max_amount:
            raise forms.ValidationError(
                _("The maximum amount is: %s")
                % intcomma(round(self.max_amount, self.decimal_places))
            )
        return amount 
開發者ID:stellar,項目名稱:django-polaris,代碼行數:16,代碼來源:forms.py

示例5: format_score

# 需要導入模塊: from django.contrib.humanize.templatetags import humanize [as 別名]
# 或者: from django.contrib.humanize.templatetags.humanize import intcomma [as 別名]
def format_score(value):
    if value is None:
        return "N/A"

    if isinstance(value, bool):
        return '\u2714' if value else '\u2718'

    elif isinstance(value, int):
        return intcomma(value)

    f = floatformat(value, 2)
    if f:
        return f

    return value 
開發者ID:chaoss,項目名稱:prospector,代碼行數:17,代碼來源:metrics.py

示例6: get_display_value

# 需要導入模塊: from django.contrib.humanize.templatetags import humanize [as 別名]
# 或者: from django.contrib.humanize.templatetags.humanize import intcomma [as 別名]
def get_display_value(self):
        """should return $100.00
        """
        value = self.get_current_value()
        if value is None:
            return ''
        return "${}.00".format(intcomma(value)) 
開發者ID:codeforamerica,項目名稱:intake,代碼行數:9,代碼來源:field_types.py

示例7: format_currency

# 需要導入模塊: from django.contrib.humanize.templatetags import humanize [as 別名]
# 或者: from django.contrib.humanize.templatetags.humanize import intcomma [as 別名]
def format_currency(self, dollars):
        """ Provides a cost estimate in formatted dollars """
        dollars = round(float(dollars), 2)
        return "$%s%s" % (intcomma(int(dollars)), ("%0.2f" % dollars)[-3:]) 
開發者ID:ekansa,項目名稱:open-context-py,代碼行數:6,代碼來源:estimator.py

示例8: format_percentage

# 需要導入模塊: from django.contrib.humanize.templatetags import humanize [as 別名]
# 或者: from django.contrib.humanize.templatetags.humanize import intcomma [as 別名]
def format_percentage(self, value):
        if value is None:
            formatted_percent = u'0'
        else:
            formatted_percent = intcomma(round(value, 3) * 100)

        return formatted_percent 
開發者ID:edx,項目名稱:edx-analytics-dashboard,代碼行數:9,代碼來源:enrollment.py

示例9: format_tip_percent

# 需要導入模塊: from django.contrib.humanize.templatetags import humanize [as 別名]
# 或者: from django.contrib.humanize.templatetags.humanize import intcomma [as 別名]
def format_tip_percent(self, value):
        if value is None:
            formatted_percent = u'0'
        else:
            formatted_percent = intcomma(round(value, 3) * 100)

        return formatted_percent 
開發者ID:edx,項目名稱:edx-analytics-dashboard,代碼行數:9,代碼來源:__init__.py

示例10: join_stats

# 需要導入模塊: from django.contrib.humanize.templatetags import humanize [as 別名]
# 或者: from django.contrib.humanize.templatetags.humanize import intcomma [as 別名]
def join_stats(d, status, sep=", "):
    joined = ""

    empty_extras = ""
    if status == Harvest.RUNNING:
        empty_extras = "Nothing yet"
    elif status == Harvest.REQUESTED:
        empty_extras = "Waiting for update"

    if d:
        for i, (item, count) in enumerate(d.items()):
            if i > 1:
                joined += sep
            joined += "{} {}".format(intcomma(count), item)
    return joined if joined else empty_extras 
開發者ID:gwu-libraries,項目名稱:sfm-ui,代碼行數:17,代碼來源:ui_extras.py

示例11: render_fund_allocation

# 需要導入模塊: from django.contrib.humanize.templatetags import humanize [as 別名]
# 或者: from django.contrib.humanize.templatetags.humanize import intcomma [as 別名]
def render_fund_allocation(self, record):
        return f'${intcomma(record.amount_paid)} / ${intcomma(record.value)}' 
開發者ID:OpenTechFund,項目名稱:hypha,代碼行數:4,代碼來源:tables.py

示例12: get_context_data

# 需要導入模塊: from django.contrib.humanize.templatetags import humanize [as 別名]
# 或者: from django.contrib.humanize.templatetags.humanize import intcomma [as 別名]
def get_context_data(self, **kwargs):
        submissions = ApplicationSubmission.objects.all()
        submission_undetermined_count = submissions.undetermined().count()
        review_my_count = submissions.reviewed_by(self.request.user).count()

        submission_value = submissions.current().value()
        submission_sum = intcomma(submission_value.get('value__sum'))
        submission_count = submission_value.get('value__count')

        submission_accepted_value = submissions.current_accepted().value()
        submission_accepted_sum = intcomma(submission_accepted_value.get('value__sum'))
        submission_accepted_count = submission_accepted_value.get('value__count')

        reviews = Review.objects.all()
        review_count = reviews.count()
        review_my_score = reviews.by_user(self.request.user).score()

        return super().get_context_data(
            submission_undetermined_count=submission_undetermined_count,
            review_my_count=review_my_count,
            submission_sum=submission_sum,
            submission_count=submission_count,
            submission_accepted_count=submission_accepted_count,
            submission_accepted_sum=submission_accepted_sum,
            review_count=review_count,
            review_my_score=review_my_score,
            **kwargs,
        ) 
開發者ID:OpenTechFund,項目名稱:hypha,代碼行數:30,代碼來源:views.py

示例13: roundpound

# 需要導入模塊: from django.contrib.humanize.templatetags import humanize [as 別名]
# 或者: from django.contrib.humanize.templatetags.humanize import intcomma [as 別名]
def roundpound(num):
    order = 10 ** math.floor(math.log10(num))
    if order > 0:
        return intcomma(int(round(num / order) * order))
    else:
        return str(int(round(num))) 
開發者ID:ebmdatalab,項目名稱:openprescribing,代碼行數:8,代碼來源:template_extras.py

示例14: _humanize

# 需要導入模塊: from django.contrib.humanize.templatetags import humanize [as 別名]
# 或者: from django.contrib.humanize.templatetags.humanize import intcomma [as 別名]
def _humanize(cost_saving):
    return intcomma(int(round(abs(cost_saving)))) 
開發者ID:ebmdatalab,項目名稱:openprescribing,代碼行數:4,代碼來源:test_measures.py

示例15: testo_euro

# 需要導入模塊: from django.contrib.humanize.templatetags import humanize [as 別名]
# 或者: from django.contrib.humanize.templatetags.humanize import intcomma [as 別名]
def testo_euro(numero, simbolo_html=False):
    euro = round(float(numero), 2)
    simbolo = "&euro;" if simbolo_html else "€"
    return ("%s%s %s" % (intcomma(int(euro)), ("%0.2f" % euro)[-3:], simbolo)).replace('.', ',') 
開發者ID:CroceRossaItaliana,項目名稱:jorvik,代碼行數:6,代碼來源:utils.py


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