On Monday 31 August 2009 05:48:18 am Daniel Roseman wrote: > On Aug 31, 11:58 am, Mike Ramirez <[email protected]> wrote: > > On Monday 31 August 2009 02:46:27 am Daniel Roseman wrote: > > > I think you're going to need to post your view code as well. It seems > > > that the form is passing itself, rather than its data, to the widget, > > > so I'd guess there's something weird about the way it's being > > > instantiated. > > > -- > > > DR. > > > > Hereyou go, nothing special. > > > > http://dpaste.com/87647/ > > > > Mike > > OK I think the problem is that you've declared the form's __init__ to > take an extra argument, userip. So after a POST, in line 6, you're > correctly instantiating your form with the extra arg. However, on a > GET, in line 26, you don't pass in any arguments at all, so the > arguments are all shifted leftwards - what should be in data ends up > in userip, etc. > > Either make sure you always pass in userip when you instantiate the > form, or (preferably) change the __init__ so that userip is in the > kwargs dictionary, and use kwargs.pop('userip') to get its value > before you hand off to super(). > -- > DR.
Ok, changed the __init__ to look like this:
class ReCaptchaForm(forms.Form):
captcha = forms.CharField(widget=ReCaptchaWidget)
def __init__(self, *args, **kwargs):
super(ReCaptchaForm, self).__init__(self, *args, **kwargs)
if kwargs.has_key('userip'):
self.userip = kwargs.pop('userip')
The view didn't change much except for this:
if request.method == "POST":
userip = request.META['REMOTE_ADDR']
form = ContactForm(request.POST, userip=userip)
I still get the same error.
Mike
--
Wanna buy a duck?
signature.asc
Description: This is a digitally signed message part.

