Ticket #6281: 6281-slugfield-formfield.patch

File 6281-slugfield-formfield.patch, 773 bytes (added by Collin Grady <cgrady@…>, 17 years ago)
  • django/db/models/fields/__init__.py

     
    951951            kwargs['db_index'] = True
    952952        super(SlugField, self).__init__(*args, **kwargs)
    953953
     954    def formfield(self, **kwargs):
     955        defaults = {'form_class': forms.RegexField, 'regex': r'^[-\w]+$',
     956                    'error_messages': {'invalid': _("This value must contain only letters, numbers, underscores or hyphens.")}}
     957        return super(SlugField, self).formfield(**defaults)
     958
    954959class SmallIntegerField(IntegerField):
    955960    def get_manipulator_field_objs(self):
    956961        return [oldforms.SmallIntegerField]
Back to Top