I believe that when a checkbox is not 'checked' it will not be in your request object ... so:
if data.has_key('s_cymru'): # it is checked else: # not checked On Aug 24, 9:28 am, vanderkerkoff <[EMAIL PROTECTED]> wrote: > hello everyone. > > I'm using a manipulator in an applications view file. > > class RegistrationManipulator(AuthenticationForm): > def __init__(self, request): > AuthenticationForm.__init__(self, request) > self.fields = ( > forms.TextField(field_name="username", > is_required=True,length=15, > maxlength=30,validator_list=[self.isValidUsername, > self.hasCookiesEnabled]), > forms.TextField(field_name="first_name", > is_required=False,length=30, maxlength=30), > > forms.PasswordField(field_name="password",is_required=True,length=15, > maxlength=30,validator_list=[self.isOkPassword]), > forms.CheckboxField(field_name="s_cymru", checked_by_default=True), > ) > I have the form element in my template > <p><label for="id_s_cymru">{% trans 'Welsh Speaking:' %}</label> > <input type="checkbox" name="s_cymru" id="id_s_cymru" /> > > And if it's ticked, I set the group_id in the save function in the > same view. > > welshie = data['s_cymru'] > if welshie == 'on': > u.groups.add(2) > Works a treat. > > However, if the checkbox is not ticked, I get this error > Key 's_cymru' not found in <MultiValueDict: {u'username': > [u'mjdavies'], u'first_name': [u'mj'], u'password': [u'password']}>" > > Has anyone got any ideas why? > > It's as if the forms.CheckboxField(field_name="s_cymru", > checked_by_default=True), line in the manipulator is not doing > anything. > > In fact it's not, I just removed it and it made no difference to the > procedure. > > I'm doing something silly, please help the dumbass --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---