mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #8040 -- SlugField now returns a proper formfield to deal with validation. Thanks Daniel Pope for the ticket and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8477 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -890,6 +890,13 @@ class SlugField(CharField):
|
||||
def get_internal_type(self):
|
||||
return "SlugField"
|
||||
|
||||
def formfield(self, **kwargs):
|
||||
defaults = {'form_class': forms.RegexField, 'regex': r'^[a-zA-Z0-9_-]+$',
|
||||
'error_messages': {'invalid': _(u"Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens.")},
|
||||
}
|
||||
defaults.update(kwargs)
|
||||
return super(SlugField, self).formfield(**defaults)
|
||||
|
||||
class SmallIntegerField(IntegerField):
|
||||
def get_manipulator_field_objs(self):
|
||||
return [oldforms.SmallIntegerField]
|
||||
|
||||
Reference in New Issue
Block a user