Login

Tag "money"

Snippet List

Integer based MoneyField

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. The python class decimal.Decimal also has a shortcoming that it is not json serializable(neither cjson nor simplejson). This money field appears as a float number to the front end, so it does not meet the headache as DecimalField. The usage is very simple. In Model: class SomeModel(models.Model): ... income = MoneyField('income') ... Then treat the attribute of the model instance as a normal float type. **Notes** If you try to use aggregation on this field, you have to convert it to float by yourself. Currently I could not find any method to fix this.

  • money
  • db
  • field
Read More
Author: Jay
  • 0
  • 1

django-pyodbc MoneyField

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. **Example:** class MyModel(models.Model): price = MoneyField()

  • money
  • convert
  • pyodbc
  • django-pyodbc
Read More

Currency filter

Formats a number in the local currency format. E.g., if `foo` is equal to `49277`, then > ` {{ foo|currency }}` would print > `$49,277` If your locale is the U.S. You can use this filter in your templates as described in the [Django documentation](http://www.djangoproject.com/documentation/templates_python/)

  • filter
  • templatetags
  • money
  • currency
  • dollars
Read More

5 snippets posted so far.