forms - Django - Changing widget on GET request according to a choice field -
i want change field widget readonly if choice of form 'yes'. code working fine initiate widget state readonly:
form:
def __init__(self, *args, **kwargs): super(accountupdate, self).__init__(*args, **kwargs) self.fields['year'].widget.attrs['readonly'] = u'readonly'
but how according choice field on request?
model:
class accountupdate(models.model): updateaddress = models.charfield(max_length=1, null=true, blank=true, choices=option_choices, default='n') address = models.charfield('your address?', max_length=50) year = models.charfield(max_length=4)
choices:
option_choices = ( ('s', 'yes'), ('n', 'no'), )
Comments
Post a Comment