# enable default\_storage to pass kwargs to python open()

**URL:** <https://forum.djangoproject.com/t/enable-default-storage-to-pass-kwargs-to-python-open/34045>\
**Category:** Django Internals\
**Created:** [August 20, 2024, 9:46pm UTC](https://forum.djangoproject.com/t/enable-default-storage-to-pass-kwargs-to-python-open/34045 "2024-08-20T21:46:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![whatisgalen](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/whatisgalen/32/23367_2.png) [@whatisgalen](https://forum.djangoproject.com/u/whatisgalen)\
**Post date:** [August 20, 2024, 9:46pm UTC](https://forum.djangoproject.com/t/enable-default-storage-to-pass-kwargs-to-python-open/34045/1 "2024-08-20T21:46:14Z")

</div>

Django file system storage `File.open()` enables passing args/kwargs to python open() as documented [here](https://docs.djangoproject.com/en/5.0/releases/5.0/#file-storage). It would be good to enable Django’s file storage `default_storage.open` to do the same. One issue that comes up is that you can’t set an encoding for files you want to open this way.

---

<div class="post-metadata">

**Author:** ![adamchainz](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/adamchainz/32/26_2.png) [@adamchainz](https://forum.djangoproject.com/u/adamchainz)\
**Post date:** [September 2, 2024, 9:33pm UTC](https://forum.djangoproject.com/t/enable-default-storage-to-pass-kwargs-to-python-open/34045/3 "2024-09-02T21:33:24Z")

</div>

I’m not sure many of these arguments make sense for non-filesystem backends, such as the in-memory one or the remote storage service backends in the popular [django-storages](https://pypi.org/project/django-storages/). Perhaps it would be better to restrict the proposal to just `encoding` ? I can see that being useful.

Any new arguments would still require cooperation from the backend to adopt them, though.

---

<div class="post-metadata">

**Author:** ![whatisgalen](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/whatisgalen/32/23367_2.png) [@whatisgalen](https://forum.djangoproject.com/u/whatisgalen)\
**Post date:** [September 3, 2024, 1:16am UTC](https://forum.djangoproject.com/t/enable-default-storage-to-pass-kwargs-to-python-open/34045/4 "2024-09-03T01:16:36Z")

</div>

totally agree re: limiting the proposal to adding kwarg encoding!
