我正在使用此工具上传带有ajax的文件: https://github.com/skoczen/django-ajax-uploader
它运行良好但我无法使用动态参数设置文件的路径(静态路径运行良好)。 以下是代码的相关部分:
urls.py:
url(r'ajax-upload$', views.import_uploader, name="my_ajax_upload")
views.py:
import_uploader = AjaxFileUploader(UPLOAD_DIR='campaigns')
JS:
var uploader = new qq.FileUploader(
{
action: "{% url 'campaigns:my_ajax_upload' %}",
element: input_element[0],
multiple: true,
onComplete: function(id, fileName, responseJSON)
{
},
onAllComplete: function(uploads)
{
},
params:
{
'csrf_token': '{{ csrf_token }}',
'csrf_name': 'csrfmiddlewaretoken',
'csrf_xname': 'X-CSRFToken',
},
});
我的路径如下:
path='campaigns/campaign_{}/participation/participant_{}/question_{}/'.format(self.campaign.id, self.participant.id, self.answers.question.id)
如何将路径的动态参数传递给AjaxFileUploader对象?