django-pyodbc MoneyField

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
from django.db import models

class MoneyField(models.DecimalField):
    
    def __init__(self, *args, **kwargs):
        # Default to the max size for SQL Server's money datatype
        kwargs['max_digits'] = kwargs.get('max_digits', 20)
        kwargs['decimal_places'] = kwargs.get('decimal_places', 2)
        super(MoneyField, self).__init__(*args, **kwargs)
    
    def get_placeholder(self, value):
        return r'CONVERT(money, %s)'

More like this

  1. Integer based MoneyField by Jay 2 years, 4 months ago
  2. Widget for Money values on Geraldo Reports by marinho 2 years, 9 months ago
  3. Read only form & model field by StanislavKraev 7 months, 2 weeks ago
  4. JSONField by Jasber 2 years, 9 months ago
  5. adding fields to User model by diverman 1 year, 6 months ago

Comments

(Forgotten your password?)