Ticket #5903: decimal-field-default.patch

File decimal-field-default.patch, 750 bytes (added by justin.driscoll@…, 17 years ago)

Overrides the base "get_default" behavior for decimal fields

  • __init__.py

     
    663663            num_chars += 1
    664664
    665665        return u"%.*f" % (self.decimal_places, value)
     666               
     667        def get_default(self):
     668        "Returns the default value for this field."
     669        if self.default is not NOT_PROVIDED:
     670            if callable(self.default):
     671                return self.to_python(self.default())
     672            return self.to_python(self.default)
     673        if not self.empty_strings_allowed or (self.null and settings.DATABASE_ENGINE != 'oracle'):
     674            return None
     675        return ""
    666676
    667677    def get_db_prep_save(self, value):
    668678        if value is not None:
Back to Top