You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

14 lines
445 B

from django.forms import CharField
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.core.validators import EMPTY_VALUES
class DigitField(CharField):
def clean(self, value):
super(DigitField, self).clean(value)
if value not in EMPTY_VALUES and not value.isdigit():
raise ValidationError(_('Please enter only digits.'))
return value