#26896 closed Bug (fixed)
FileSystemStorage no longer accepts reverse_lazy as base_url
Reported by: | tpazderka | Owned by: | nobody |
---|---|---|---|
Component: | File uploads/storage | Version: | 1.8 |
Severity: | Normal | Keywords: | storage, reverse_lazy |
Cc: | Claude Paroz | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Changes introduced with commit [fb9d8f06] fixing #22717 causes FileSystemStorage
to evaluate the content of base_url
uppon initialization.
This causes issues if the base_url
is defined as reverse_lazy
as it is resolved and can cause ImportError
.
I think that the laziness of the base_url
should be preserved. Either the check for the trailing slash can me moved to path generation or the __init__
can be updated to expect reverse_lazy
as base_url
.
Attachments (1)
Change History (9)
comment:1 by , 8 years ago
Description: | modified (diff) |
---|
by , 8 years ago
Attachment: | 0001-Test-for-reverse_lazy.patch added |
---|
Patch for tests/file_storage/tests.py
comment:2 by , 8 years ago
Not exactly our usecase as our failure is on ImportError
which seems hard to test, but I hope that this patch shows the issue we are having.
The basic idea is that reverse_lazy
should remain lazy as long as possible. Resolving the base_url
on init()
defeats the purpose of using reverse_lazy
there.
comment:3 by , 8 years ago
Cc: | added |
---|
Should we skip that check if base_url
is lazy or do you see some alternative?
comment:4 by , 8 years ago
We should explore making base_url
a descriptor, that might help delaying the check.
comment:5 by , 8 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:6 by , 8 years ago
Has patch: | set |
---|
I have created a pull request https://github.com/django/django/pull/6989 which omitts the check if the base_url
is not of string_types
.
Could you provide a test for
tests/file_storage/tests.py
that demonstrates your use case?