ばりでーた

ちょっと自分メモ用に再掲載


from django.core import validators
from django.conf import settings
import re

zen_num = re.compile(u'[\uFF10-\uFF19]')
zen_kana = re.compile(u'[\u30A1-\u30F6]')
zen_hira = re.compile(u'[\u3041-\u3093]')

han_kana = re.compile(u'[\uFF61-\uFF9F]')
def isNotIncludeHalfWidthKatakana(field_data, all_data):
from_data = unicode(field_data, settings.DEFAULT_CHARSET)
if han_kana.search(from_data) is not None:
raise validators.ValidationError(_('Half-width Kana characters are not allowed.'))