Hacker News new | ask | show | jobs
by vivekd 3409 days ago
Sorry typo, it should be the second blank is the empty space where the user input goes.

I just tried your solution with cleaned_data["formfield1"] instead of cleaned_data("formfield1","") and it didn't work for me, it came back with the following error message when I submitted the form:

>'builtin_function_or_method' object is not subscriptable

I think you have to have the empty quotes after the form field and I think that's what's capturing the user input

so here "form.cleaned_data("formfield1","") seems to be telling django the form name and then the second field is where the associated user input goes which is then passed to the model.

1 comments

wait just tried the code again, you were right, I don't need the second empty string. I was using [] with get and it wasn't working.

so it seems the right way is form.cleaned_data.get('formfieldvalue')

or

form.cleaned_data[formfieldvalue']

if you don't want to use get