Ticket #4415: positiveintegerfield.diff

File positiveintegerfield.diff, 660 bytes (added by django@…, 17 years ago)

PositiveIntegerField as newforms.IntergerField with min_value

  • django/db/models/fields/__init__.py

     
    838838    def get_manipulator_field_objs(self):
    839839        return [oldforms.PositiveIntegerField]
    840840
     841    def formfield(self, **kwargs):
     842        defaults = {'min_value': 0}
     843        defaults.update(kwargs)
     844        return super(PositiveIntegerField, self).formfield(**defaults)
     845
    841846class PositiveSmallIntegerField(IntegerField):
    842847    def get_manipulator_field_objs(self):
    843848        return [oldforms.PositiveSmallIntegerField]
Back to Top