djangosnippets.org: Latest snippets tagged with 'money'https://djangosnippets.org/tags/money/2014-03-11T10:02:36.641222-05:00Fixed-point Decimal model field with integer storage
2014-03-11T10:02:36.641222-05:00lanzzhttps://djangosnippets.org/snippets/3035/<p>Fixed-point model field based on <code>IntegerField</code> and <code>DecimalField</code>. Represented as <code>Decimal</code> in Python for accurate calculations, stored as integer in the database. Configurable decimal places, defaults to 2.</p>
Freely redistributableInteger based MoneyField
2009-09-24T23:53:31.935377-05:00Jayhttps://djangosnippets.org/snippets/1741/<p>It is supposed the aggregation on integer is fast than numeric type in database duo to how they are stored as numeric is represented as string. As money only have 2 decimal place, it can be converted to an Integer despite of its decimal point.</p>
<p>The python class decimal.Decimal also …</p>
Freely redistributabledjango-pyodbc MoneyField
2008-10-30T11:25:27.670660-05:00Tarkenhttps://djangosnippets.org/snippets/1161/<p>This is a very small, simple piece of code, but essential for using fields of type 'money' on MS SQL Server, through FreeTDS. This took me quite some time to hunt down, as get_placeholder() is in fact an undocumented feature.</p>
<p><strong>Example:</strong></p>
<pre><code>class MyModel(models.Model):
price = MoneyField()
</code></pre>
Freely redistributableCurrency filter
2008-01-17T19:15:34.060832-06:00kljensenhttps://djangosnippets.org/snippets/552/<p>Formats a number in the local currency format. E.g., if <code>foo</code> is equal to <code>49277</code>, then</p>
<blockquote>
<p><code>{{ foo|currency }}</code></p>
</blockquote>
<p>would print</p>
<blockquote>
<p><code>$49,277</code></p>
</blockquote>
<p>If your locale is the U.S. You can use this filter in your templates as described in the <a href="http://www.djangoproject.com/documentation/templates_python/">Django documentation</a></p>
Freely redistributabledollarize numbers
2007-04-04T02:25:42.769225-05:00alexdonghttps://djangosnippets.org/snippets/152/<p>Usage: <code>{{ price|dollarize }}</code></p>
Freely redistributable