[Django] #34530: Remove docs suggestion to use lambda for models.FileField(storages=...)

9 views
Skip to first unread message

Django

unread,
May 2, 2023, 7:28:10 AM5/2/23
to django-...@googlegroups.com
#34530: Remove docs suggestion to use lambda for models.FileField(storages=...)
-----------------------------------------+------------------------
Reporter: Ran Benita | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 4.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
The file storage docs
https://docs.djangoproject.com/en/4.2/topics/files/#using-a-callable
currently suggest the following:

{{{
upload = models.FileField(storage=lambda: storages["custom_storage"])
}}}

The migrations serializer however doesn't handle lambdas. So I think this
paragraph should just be removed (the previous paragraph is good enough,
using a named function).

Side note: it might have been nice to allow `FileField(storage="foo")`
which will lazily take `storages["foo"]` and thus avoid the callable
annoyance? But that's unrelated to this ticket.

--
Ticket URL: <https://code.djangoproject.com/ticket/34530>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 2, 2023, 7:32:49 AM5/2/23
to django-...@googlegroups.com
#34530: Remove docs suggestion to use lambda for models.FileField(storages=...)
-------------------------------+------------------------------------

Reporter: Ran Benita | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by David Sanders):

* stage: Unreviewed => Accepted


Comment:

Hi bluetech!

Thanks for identifying this 👍 Interested in submitting a PR?

--
Ticket URL: <https://code.djangoproject.com/ticket/34530#comment:1>

Django

unread,
May 2, 2023, 7:36:17 AM5/2/23
to django-...@googlegroups.com
#34530: Remove docs suggestion to use lambda for models.FileField(storages=...)
-------------------------------+------------------------------------
Reporter: Ran Benita | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by David Sanders):

> So I think this paragraph should just be removed (the previous paragraph
is good enough, using a named function).

Personally I think an example involving `storages` is worth keeping though
🤷‍♂️

> Side note: it might have been nice to allow FileField(storage="foo")
which will lazily take storages["foo"] and thus avoid the callable
annoyance? But that's unrelated to this ticket.

Seems like something worth raising on the forum.

--
Ticket URL: <https://code.djangoproject.com/ticket/34530#comment:2>

Django

unread,
May 2, 2023, 7:36:35 AM5/2/23
to django-...@googlegroups.com
#34530: Remove docs suggestion to use lambda for models.FileField(storages=...)
-------------------------------+------------------------------------
Reporter: Ran Benita | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0

-------------------------------+------------------------------------
Changes (by David Sanders):

* easy: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/34530#comment:3>

Django

unread,
May 2, 2023, 7:44:23 AM5/2/23
to django-...@googlegroups.com
#34530: Remove docs suggestion to use lambda for models.FileField(storages=...)
-------------------------------+------------------------------------
Reporter: Ran Benita | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by Ran Benita):

Thanks David, agreed about keeping an example using `storages`. I sent a
PR.

> Seems like something worth raising on the forum.

If I have some time I'll try checking if it makes sense first :)

--
Ticket URL: <https://code.djangoproject.com/ticket/34530#comment:4>

Reply all
Reply to author
Forward
0 new messages