what's wrong?
File "trunk/website/auth/user/emailchange/views.py" in email_change_view
102. context['form'] = form
File "/usr/local/lib/python2.6/dist-packages/django/template/context.py" in __setitem__
39. self.dicts[-1][key] = value
Exception Type: TypeError at /accounts/email/change/
Exception Value: 'SendUsernameForm' object does not support item assignment
Here is the Code
else:
form = EmailChangeForm(username=request.user.username)
context = RequestContext(request, extra_context)
context['form'] = form
return render_to_response(template_name, context_instance=context)
HTML Code:
<开发者_如何学Pythonform method="post">{% csrf_token %}
{{ form.as_p }}
<p><input type="submit" value="Change email address" /></p>
</form>
Any ideas?
Add form
to extra_context
dic, not context
.
The error is literally saying, context['form']
is invalid, so it's a good place to start wondering if RequestContext should be used in that fashion.
RequestContext docs: http://docs.djangoproject.com/en/dev/ref/templates/api/#django.template.RequestContext
else:
form = EmailChangeForm(username=request.user.username)
extra_context['form'] = form
context = RequestContext(request, extra_context)
精彩评论