#34530 closed Cleanup/optimization (fixed)
Remove docs suggestion to use lambda for models.FileField(storage=...)
Reported by: | Ran Benita | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 4.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
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.
Change History (9)
comment:1 by , 19 months ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 19 months ago
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 storagesfoo and thus avoid the callable annoyance? But that's unrelated to this ticket.
Seems like something worth raising on the forum.
comment:3 by , 19 months ago
Easy pickings: | set |
---|
comment:4 by , 19 months ago
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 :)
comment:5 by , 19 months ago
Has patch: | set |
---|---|
Summary: | Remove docs suggestion to use lambda for models.FileField(storages=...) → Remove docs suggestion to use lambda for models.FileField(storage=...) |
comment:7 by , 19 months ago
Triage Stage: | Accepted → Ready for checkin |
---|---|
Type: | Uncategorized → Cleanup/optimization |
Hi bluetech!
Thanks for identifying this 👍 Interested in submitting a PR?