djangosnippets.org: Latest snippets tagged with 'comma'https://djangosnippets.org/tags/comma/2012-05-17T17:23:26.180755-05:00MultiSelectField with comma separated values (Field + FormField)
2012-05-17T17:23:26.180755-05:00quinodehttps://djangosnippets.org/snippets/2753/<p>Daniel Roseman's snippet, updated will all fixes mentioned in the comments of the first version + some other things to make it work under Django 1.4.<br />
South, and dumpdata are working.</p>
<p>There's an ugly int(....) at the validate function in order to cast each value as an integer before comparing …</p>
Freely redistributableConverts 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 redistributableMany2Many comma separated form field
2010-01-31T15:22:43.128008-06:00haloweenhttps://djangosnippets.org/snippets/1903/<p>Useful in sumbiting data .
Remember to use form.save_m2m() :)</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 redistributable(en-US) Humanized Decimal Field
2008-07-01T14:47:19.431231-05:00ActionScriptedhttps://djangosnippets.org/snippets/842/<p>Simple DecimalField class extension that automatically adds formatting and validation for comma-separated "decimals". Works wonderfully for price fields.
</p>
<p>Could be extended to strip dollar signs or to be locale-agnostic.
</p>
Freely redistributableNewforms field for decimals with a comma
2008-03-12T05:50:20.027111-05:00jonasvphttps://djangosnippets.org/snippets/643/<p>This might be handy in countries where decimals are entered with a comma separating the decimal places from the integer part (for instance in Germany). It lets user enter and displays all decimals with a comma separator.</p>
<p>I ran into this problem and couldn't find a clean internationalized way of …</p>
Freely redistributableSeparatedValuesField
2007-12-05T07:28:00.905678-06:00jezdezhttps://djangosnippets.org/snippets/497/<p>A Django newforms field which takes another newforms field during
initialization and validates every item in a comma-separated list with
this field class. Please use it like this:</p>
<pre><code>from django.newforms import EmailField
emails = CommaSeparatedValuesField(EmailField)
</code></pre>
<p>You would be able to enter a string like "john@doe.com,guido@python.org"
because every email address would …</p>
Freely redistributable