Index: tests/modeltests/model_forms/models.py
===================================================================
--- tests/modeltests/model_forms/models.py (revision 8671)
+++ tests/modeltests/model_forms/models.py (working copy)
@@ -98,6 +98,12 @@
def __unicode__(self):
return self.description
+class CommaSeparatedInteger(models.Model):
+ field = models.CommaSeparatedIntegerField(max_length=20)
+
+ def __unicode__(self):
+ return self.field
+
__test__ = {'API_TESTS': """
>>> from django import forms
>>> from django.forms.models import ModelForm, model_to_dict
@@ -1050,4 +1056,26 @@
+>>> class CommaSeparatedIntegerForm(ModelForm):
+... class Meta:
+... model = CommaSeparatedInteger
+
+>>> f = CommaSeparatedIntegerForm().fields['field']
+>>> f.clean('1,2,3')
+u'1,2,3'
+>>> f.clean('1a,2')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid value.']
+>>> f.clean(',,,,')
+u',,,,'
+>>> f.clean('1.2')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid value.']
+>>> f.clean('1,,2')
+u'1,,2'
+>>> f.clean('1')
+u'1'
+
"""}