mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #8556: added a useful formfield to CommaSeparatedIntegerField. gkelly, mattmcc, and kratorius all contributed portions of this patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8682 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -394,7 +394,17 @@ class CharField(Field):
|
||||
|
||||
# TODO: Maybe move this into contrib, because it's specialized.
|
||||
class CommaSeparatedIntegerField(CharField):
|
||||
pass
|
||||
def formfield(self, **kwargs):
|
||||
defaults = {
|
||||
'form_class': forms.RegexField,
|
||||
'regex': '^[\d,]+$',
|
||||
'max_length': self.max_length,
|
||||
'error_messages': {
|
||||
'invalid': _(u'Enter only digits separated by commas.'),
|
||||
}
|
||||
}
|
||||
defaults.update(kwargs)
|
||||
return super(CommaSeparatedIntegerField, self).formfield(**defaults)
|
||||
|
||||
ansi_date_re = re.compile(r'^\d{4}-\d{1,2}-\d{1,2}$')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user