djangosnippets.org: Latest snippets tagged with 'number'https://djangosnippets.org/tags/number/2012-03-14T16:02:38.243837-05:00Converts an integer or floating-point number or a string to a string containing the delimiter character (default comma) after every delimeter_count digits (by default 3 digits)
2012-03-14T16:02:38.243837-05:00pikhovkinhttps://djangosnippets.org/snippets/2716/<p>Converts an integer or floating-point number or a string to a string containing the delimiter character (default comma) after every delimeter_count digits (by default 3 digits)</p>
Freely redistributableformat_thousands
2011-06-28T14:56:49.198163-05:00cootetomhttps://djangosnippets.org/snippets/2473/<p>Template filter to format a number so that it's thousands are separated by commas. </p>
<p>{{ number|format_thousands }}</p>
Freely redistributableRegex Comma Number
2008-10-24T18:11:23.448329-05:00petryhttps://djangosnippets.org/snippets/1155/<p>Format Number Based on Regular Expression</p>
<p><strong>Examples</strong></p>
<blockquote>
<p><em>{{.1234|regex_comma_number:'%.4f'}}
</em>'0.1234'</p>
<p><em>{{100|regex_comma_number:'%i'}}
</em>'100'</p>
<p><em>{{ 234.5678|regex_comma_number:'%.4f'}}
</em>'234.5678'</p>
<p><em>{{234.5678|regex_comma_number:'$%.4f'}}
</em>'$234.5678'</p>
<p><em>{{1000|regex_comma_number:'%i'}}
</em>'1,000'</p>
<p><em>{{1234.5678|regex_comma_number:'%.4f'}}
</em>'1,234.5678'</p>
<p><em>{{1234.5678|regex_comma_number:'$%.4f'}}
</em>'$1,234.5678'</p>
<p><em>{{1000000|regex_comma_number:'%i'}}
</em>'1,000,000'</p>
<p><em>{{1234567.5678|regex_comma_number:'%.4f'}}
</em>'1,234,567.5678'</p>
<p><em>{{1234567.5678|regex_comma_number:'$%.4f'}}
</em>'$1,234,567.5678'</p>
<p><em>{{-100|regex_comma_number:'%i'}}
</em>'-100'</p>
<p><em>{{-234.5678|regex_comma_number:'%.4f'}}
</em>-234.5678'</p>
<p><em>{{-234.5678|regex_comma_number:'$%.4f'}}
</em>'$-234.5678'</p>
<p><em>{{-1000|regex_comma_number:'%i'}}
</em>'-1,000'</p>
<p><em>{{-1234.5678|regex_comma_number:'%.4f'}}
</em>'-1,234.5678'</p>
<p><em>{{-1234.5678|regex_comma_number:'$%.4f'}}
</em>'$-1,234.5678'</p>
<p><em>{{-1000000|regex_comma_number:'%i'}}
</em>'-1,000,000'</p>
<p><em>{{-1234567.5678|regex_comma_number:'%.4f'}}
</em>'-1,234,567.5678'</p>
<p><em>{{-1234567.5678|regex_comma_number:'$%.4f'}}
</em>'$-1,234,567.5678'`</p>
</blockquote>
Freely redistributableNewforms Validation of Credit Card Numbers
2008-05-19T23:01:07.222928-05:00humphreymurrayhttps://djangosnippets.org/snippets/764/<p>Some functions and newforms fields for validating credit card numbers, and their expiry dates.
</p>
<p>In my project, I have all of the credit card functions in a file called creditcards.py
</p>
<p>Just as an overview: To validate a credit card number there are a few steps:
1. Make sure the number …</p>
Freely redistributable