本文整理汇总了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('.', ',')