1. MultiValueDictKeyError
Possible cause and solutions:
- There is no dict key named ‘user’, or you have a naming conflict.
In views.py your code
If you use GET method:
request.GET.get('user') #instead of request.GET['user']
If you use POST method:
request.POST.get('user') #instead of request.POST['user']
2. CSRF verification failed. Request aborted
Possible cause and solutions:
Add {% csrf_token %}:
<form action="" method="POST"> {% csrf_token %} ...... ...... </form>
Some solutions may suggest adding two lines in settings.py:
‘django.middleware.csrf.CsrfViewMiddleware’,
‘django.middleware.csrf.CsrfResponseMiddleware’,but there is no need to add these two lines if your django version is above 1.3. You just need to annotate them.
In views.py use RequestContext instead of Context:
from django.template import RequestContext #...... return render_to_response(‘index.html’, {'param1′: 'aaa','param2′: 'bbb',}, context_instance=RequestContext(request) )