bradleyg / django-s3direct

Directly upload files to S3 compatible services with Django.
MIT License
653 stars 234 forks source link

Widget's `get_context` is not called, leading to missing `widget` parameter in template context #184

Open rollcat opened 5 years ago

rollcat commented 5 years ago

I've ran into this when digging around, trying to add an "accept" parameter to the underlying <input type="file"/> tag to restrict file type choice in the picker dialog. I've started by forking the template and adding {% include "django/forms/widgets/attrs.html" %}, as is used in the base input widget template.

Turns out widget is missing from the template context, and the context itself is supplied inline in S3DirectWidget's render method, ignoring get_context on the base class and not allowing an override in a subclass.

I realise the widget parameter in this template context would be quite ambiguous, considering that this is a composite widget with very specific behaviour defined indirectly via frontend and settings, but I think it would be beneficial under the "I know what I'm doing, please let me write less code" circumstances - I can prepare a PR to address this.