Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: