A Cars forum. AutoBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » AutoBanter forum » Auto makers » Chrysler
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

django-ajax-uploader how to send csrf_token with fine-uploader 3.5.0



 
 
Thread Tools Display Modes
  #1  
Old July 18th 13, 07:10 AM posted to rec.autos.makers.chrysler
[email protected]
external usenet poster
 
Posts: 1
Default django-ajax-uploader how to send csrf_token with fine-uploader 3.5.0

I am implementing django-ajax-uploader in a project, but I want to use latest version of fineuploader that is currently under 3.5.0, supposedly, as documentation says the only thing I should do to send csrf_token is putting it inside customHeaders dictionary:

If you want to use the latest version of Fine Uploader, as valum's file-uploader is now called, instead of the one bundled with django-ajax-uploader, you can do so by replacing the params arguments in the above template with the following customHeaders:

customHeaders: { 'X-CSRFToken': '{{ csrf_token }}', },

Here is my full code:

....
<h1>qq-file-uploader</h1>
<div id="upload-button" class="btn btn-primary"><i class="icon icon-cloud-upload icon-white"></i> Selecciona un archivo</div>
<div id="file-upload"></div>
</form>
{% endblock %}

{% block styles %}
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}js/libs/jquery.fineuploader-3.5.0/fineuploader-3.5.0.css"/>
{% endblock %}

{% block javascript %}
<script type="text/javascript" src="{{ STATIC_URL }}js/libs/jquery.fineuploader-3.5.0/jquery.fineuploader-3.5.0.min.js"></script>
<script type="text/javascript">
$(function(){
$('div#file-upload').fineUploader({
customFields: {
'X-CSRFToken': '{{ csrf_token }}'
},
request: {
endpoint: '{% url 'documents:qq_file_uploader' %}'
},
button: $('div#upload-button'),
multiple: false,
});
});
</script>
{% endblock %}
In my views.py I have: qq_file_uploader = AjaxFileUploader()

And everytime I try to upload any file within the view a I got a 403 error: CSRF verification failed. Request aborted.
source http://www.code.mycodetips.com/17702...-fine-uploader
Ads
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ajax is a superstar! Kate[_8_] Jeep 0 March 11th 10 11:38 AM
buy product send web [email protected] Technology 0 December 18th 07 07:16 PM
Another List of headers to send to Cox.net 24Bit® Auto Photos 6 December 1st 06 03:17 AM
trying to send pics Laredo Muchacho Jeep 10 August 31st 06 12:15 PM
Let's send some pirates over to Williams! :) Byron Forbes Simulators 0 August 23rd 05 03:11 PM


All times are GMT +1. The time now is 12:35 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 AutoBanter.
The comments are property of their posters.