Ticket #4415: 4415_fields.diff

File 4415_fields.diff, 1.0 KB (added by oggie_rob, 17 years ago)

formfield method changes to PositiveIntegerField and PositiveSmallIntegerField

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

     
    910910class PositiveIntegerField(IntegerField):
    911911    def get_manipulator_field_objs(self):
    912912        return [oldforms.PositiveIntegerField]
     913   
     914    def formfield(self, **kwargs):
     915        defaults = {'min_value': 0}
     916        defaults.update(kwargs)
     917        return super(PositiveIntegerField, self).formfield(**defaults)
    913918
    914919class PositiveSmallIntegerField(IntegerField):
    915920    def get_manipulator_field_objs(self):
    916921        return [oldforms.PositiveSmallIntegerField]
    917922
     923    def formfield(self, **kwargs):
     924        defaults = {'min_value': 0}
     925        defaults.update(kwargs)
     926        return super(PositiveSmallIntegerField, self).formfield(**defaults)
     927
    918928class SlugField(CharField):
    919929    def __init__(self, *args, **kwargs):
    920930        kwargs['max_length'] = kwargs.get('max_length', 50)
Back to Top