Why does the commented out code work, while the other code returns开发者_如何学运维 a BoundField error? Shouldn't they be equivalent?
form = PostForm(request.POST)
post = Post(title = form['title'], details = form['details'])
#post = Post(title = request.POST['title'], details = request.POST['details'])
Also, I fear the title to this question makes no sense.
No, they're not equivalent.
form.data['title']
would be the equivalent of request.POST['title']
And if you want the processed data, try this:
form.is_valid()
form.cleaned_data['title']
精彩评论