Ticket #8556: 8556-1.diff
File 8556-1.diff, 2.1 KB (added by , 16 years ago) |
---|
-
django/db/models/fields/__init__.py
394 394 395 395 # TODO: Maybe move this into contrib, because it's specialized. 396 396 class CommaSeparatedIntegerField(CharField): 397 pass 397 def formfield(self, **kwargs): 398 defaults = { 399 'form_class': forms.RegexField, 400 'regex': '^[\d,]+$', 401 'max_length': self.max_length, 402 } 403 defaults.update(kwargs) 404 return super(CommaSeparatedIntegerField, self).formfield(**defaults) 398 405 399 406 ansi_date_re = re.compile(r'^\d{4}-\d{1,2}-\d{1,2}$') 400 407 -
django/contrib/admin/options.py
94 94 kwargs['widget'] = widgets.AdminIntegerFieldWidget 95 95 return db_field.formfield(**kwargs) 96 96 97 # For CommaSeparatedIntegerFields, add a custom CSS class. 98 if isinstance(db_field, models.CommaSeparatedIntegerField): 99 kwargs['widget'] = widgets.AdminCommaSeparatedIntegerFieldWidget 100 return db_field.formfield(**kwargs) 101 97 102 # For TextInputs, add a custom CSS class. 98 103 if isinstance(db_field, models.CharField): 99 104 kwargs['widget'] = widgets.AdminTextInputWidget -
django/contrib/admin/widgets.py
236 236 if attrs is not None: 237 237 final_attrs.update(attrs) 238 238 super(AdminIntegerFieldWidget, self).__init__(attrs=final_attrs) 239 240 class AdminCommaSeparatedIntegerFieldWidget(forms.TextInput): 241 def __init__(self, attrs=None): 242 final_attrs = {'class': 'vCommaSeparatedIntegerField'} 243 if attrs is not None: 244 final_attrs.update(attrs) 245 super(AdminCommaSeparatedIntegerFieldWidget, self).__init__(attrs=final_attrs)