Django and ajax image file upload errors and csrf
- by sharkfin
I tried out Alex Kuhl's ajax script to upload images to Django 1.4.
My first question is why I'm getting an empty page with firebug telling me I have two errors:
fileuploader.js (line 4):
syntax error
<!DOCTYPE html>
In my template html:
qq is not defined
var uploader = new qq.FileUploader( {
Here is my entire html file for it:
http://pastebin.com/NjbV5gMn
This post suggests that either some script has 404'd or the src attribute is empty, which would cause the doctype error. But that doesn't seem to be the case here. As for why qq is not defined, I'm not sure what is wrong. Django can clearly find the fileuploader.js just fine from my static folder.
My second question is why the ajax code uses {{ csrf_token }} instead of {% csrf_token %}. But if I use {% csrf_token %}, I get the firebug error:
missing } after property list
'csrf_token': '<div style='display:none'<input type='hidden' name='csrfmiddlewaretoken' value='Cx0zFFak6OLgrHiAnFa3k4BPDmn4BgoT' /</div',