I am using django 1.4 with bootstrap. I am getting verification error even when I have included the token. I have also included the requestcontext in the view and everything that is written in the django documentation. Here's my code:
template
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<form action="/home/create/" method="POST" id="cform" enctype="multipart/form-data">{% csrf_token %}
{{ form.as_p }}
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Complaint Form</h4>
</div>
<div class="modal-body">
<div class="bs-docs-example">
<p> TYPE </p>
<select id="Type" class="selectpicker" title="Choose a category" form=cform>
<option>Air Conditioning</option>
<option>Plumbing</option>
<option>Carpentry</option>
<option>Housekeeping</option>
<option>Electricity</option>
<option>Masonry</option>
<option>Lifts</option>
<option>Parking</option>
<option>Fire</option>
<option>Civil</option>
<option>Pest Control</option>
<option>Miscellaneous</option>
</select>
</div>
<div class="bs-docs-example">
<br>
<p> BLOCK </p>
<select id="block" class="selectpicker" title="Choose a building" form=cform>
<option>Academic Block</option>
<option>Dinning Block</option>
<option>Faculty Housing</option>
<option>Library</option>
<option>Girls' Hostel</option>
<option>Boys' Hostel</option>
</select>
</div>
<div class="bs-docs-example">
<br>
<p> EXACT LOCATION </p>
<input type="text" class="form-control" id="location" name="elocation" style="width: 100%; height: 50px"> </textarea>
</div>
<div class="bs-docs-example">
<br>
<p> DESCRIPTION </p>
<input type="text" class="form-control" id="description" name="elocation" style="width: 100%; height: 100px"> </textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary" value="Save">Submit</button>
</div>
</div>
</div>
</form>
</div>
Views.py
def myComplaint(request):
if request.method == "POST":
form = UploaderForm(request.POST)
if form.is_valid():
a = form.save()
messages.add_message(request, messages.SUCCESS, "You Article was added")
return HttpResponseRedirect('/home')
else:
form = UploaderForm()
args = {}
args.update(csrf(request))
args['form'] = form
return render_to_response("home.html", args)
Thanks in advance!
Additional Info Just checked my post method using HTTPFox and it's sending the csrf token. Is there anyway to ensure that my view is getting the csrf token or not?