[ 3 posts ]

Adam Murphy

  • Username: empirasign
  • Joined: Thu Feb 09, 2012 7:20 pm
  • Posts: 14
  • Offline
  • Profile

Django CSRF support for YUI 3.5 Uploader

Post Posted: Mon May 14, 2012 12:50 pm
+5-
Through some Googling, I had seen others have not been been to make YUI Uploader play nice with Django's CSRF protection. This may be a self-evident solution, but I thought I'd post in anyway given 1: it works, 2: past troubles with Django CSRF and YUI Uploader. I tested it when YUI Uploader executed via html5 or flash.

For the example on this page:
Multiple Files Upload with Transparent Overlay Button
http://yuilibrary.com/yui/docs/uploader/uploader-multiple.html

only two lines of code need to be added, and one change made

new lines:
var csrf_value = Y.Cookie.get("csrftoken");
postVarsPerFile: {'csrfmiddlewaretoken': csrf_value}

change to seed line (cookie added):
YUI({filter:"raw"}).use("uploader", "cookie", function(Y) {

this is all saved on a github gist:
https://gist.github.com/2696607

Dav Glass

  • Username: davglass
  • Joined: Thu Aug 28, 2008 9:28 am
  • Posts: 2088
  • Location: Marion, IL, US
  • Twitter: davglass
  • GitHub: davglass
  • Gists: davglass
  • IRC: davglass
  • Offline
  • Profile
Tags:

Re: Django CSRF support for YUI 3.5 Uploader

Post Posted: Mon May 14, 2012 2:28 pm
+0-
Thanks Adam! This should be added to the Uploader landing page as an example for others.

Allen Rabinovich

YUI Developer

  • YUI Developer
  • Offline
  • Profile

Re: Django CSRF support for YUI 3.5 Uploader

Post Posted: Mon May 14, 2012 10:19 pm
+0-
Hi Adam,

Thanks for suggesting this. The ticket tracking this issue is here:
http://yuilibrary.com/projects/yui3/ticket/2532313
  [ 3 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum