I'm using jquery ajaxfileupload plugin http://www.phpletter.com/Our-Projects/AjaxFileUpload/ to upload images with Django in server-side. I've also done the ajax setup which I saw here Django CSRF check failing with an Ajax POST request But still I'm getting 403 Forbidden: csrf verification failed.
Here is the client side script: http://jsfiddle.net/rkumarnirmal/FSDPH/
Here is the Django code:
def backgroundview(request):
if request.is_ajax():
b = request.POST.get('fileToUpload')
try:
g = BackgroundModel.objects.get(user=request.user)
except CoverModel.DoesNotExist:
bm = BackgroundModel(background=b)
bm.user = request.user
bm.save()
else:
g.background = b
g.save()
return HttpResponse("")
Could anyone help me?
Thanks!