jeanphix / django-resumable

django backend for resumable.js xhr uploads.
61 stars 21 forks source link

no els found for input name=data-upload-url #12

Open tamarmot opened 7 years ago

tamarmot commented 7 years ago

After upgrading to django 1.11 and bootstrap4 alpha, my django-resumable is no longer getting initialized properly. In the constructor, I see that it is searching for inputs with a name equal to data-upload-url, but there are no such elements. When I tried to manually search for my input field button to call initField, that also does not seem to work.

This system used to work perfectly for us; we have everything correct in terms of installation, installed apps, including javascript files etc. I've also tried pip-installing your latest code from github but no joy.

I'm thinking there is an issue with how the template is getting generated. I'm using form.as_p, and the generated html is:

<p><label for="id_sourceFile">GeoTiff File:</label> <input id="id_sourceFile-path" type="hidden" name="sourceFile-path" value="None">
<input type="file" name="sourceFile" id="id_sourceFile">
<span class="helptext">
    Select a single file to upload
</span>
</p>

Any suggestions? Thanks.

tamarmot commented 7 years ago

Ah -- I correct myself. When I manually tell django-resumable to init my field, I move on to the next issue. Here is how I can init my field: var el = $('input#id_sourceFile'); dj.initField(el[0]);

and now resumable.js is failing in the getTarget method.

Ryochan7 commented 6 years ago

I was running into this problem while testing django-resumable. The data-upload-url attribute was not being rendered for the ResumableFileField form field so the DjangoResumable JS class would not work. After some digging, I found out that the ResumableFileInput widget was purging the set data-upload-url attr due to a bad build_attrs call. One minor change to ResumableFileInput.render was enough to fix the problem (widgets.py#L47).

attrs = self.build_attrs(self.attrs, attrs)

https://github.com/jeanphix/django-resumable/blob/dev/resumable/widgets.py#L47

Someone had fixed the problem in a fork but I didn't find that changed version until after I figured it out on my end.

https://github.com/xtranophilist/django-resumable/commit/a49f4bf7ea45ab4a8456999a716937f6779b990a