###################################### modelfields.py ######################################
class FSISBNField(models.CharField):
def __init__(self, *args, **kwargs):
kwargs['max_length'] = 13
super(FSISBNField, self).__init__(*args, **kwargs)
def formfield(self, **kwargs):
kwargs['widget'] = FSAltISBNWidget()
return super(FSISBNField, self).formfield(**kwargs)
###################################### widgets.py #########################################
class AltISBNWidget(forms.TextInput):
def __init__(self, language=None, attrs={}):
super(AltISBNWidget, self).__init__(attrs=attrs)
def render(self, name, value, attrs={}):
if (not value) or len(str(value)) < 2:
return super(FSAltISBNWidget, self).render(name, value, attrs)
return super(FSAltISBNWidget, self).render(name, value, attrs) + mark_safe("""