本文整理匯總了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
示例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)
示例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))
示例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
示例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
示例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))
示例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:])
示例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
示例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
示例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
示例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)}'
示例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,
)
示例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)))
示例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))))
示例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 = "€" if simbolo_html else "€"
return ("%s%s %s" % (intcomma(int(euro)), ("%0.2f" % euro)[-3:], simbolo)).replace('.', ',')