FormWizard fails on forms with BooleanField when field is unselected
|Reported by:||anonymous||Owned by:||mcroydon|
|Severity:||Keywords:||FormWizard, BooleanField, hash failure|
|Cc:||rajesh.dhawan@…, dev@…||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Description (last modified by )
The form wizard fails to match its security hash when processing a form containing at least one BooleanField where the BooleanField's checkbox is unselected (e.g. False). This results in (on my machine) the form containing the BooleanField being redisplayed. If *all* the BooleanFields on a form are selected, it appears to work correctly.
I was able to workaround (not fix) by overriding the security_hash method as follows:
def security_hash(self, request, form): for bf in form: if bf.field.__class__ != BooleanField: data = [(bf.name, bf.data or u'')] + [settings.SECRET_KEY] # Use HIGHEST_PROTOCOL because it's the most efficient. It requires # Python 2.3, but Django requires 2.3 anyway, so that's OK. pickled = pickle.dumps(data, protocol=pickle.HIGHEST_PROTOCOL) return md5.new(pickled).hexdigest()
The problem appears (to my untrained eye) to be in the line assigning the value of data where bf.data = False and thus gets assigned .
I'm using SVN 7412.
Change History (17)
comment:1 Changed 8 years ago by
|Component:||Uncategorized → django.contrib.formtools|
|Patch needs improvement:||unset|