Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Websites UFRPE
Django Private Storage
Commits
0e9c2fea
Commit
0e9c2fea
authored
Jan 11, 2017
by
Diederik van der Boor
Browse files
Fix url reversing in Python 3
parent
f3e7e6d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
private_storage/storage.py
View file @
0e9c2fea
...
...
@@ -3,6 +3,8 @@ Django Storage interface
"""
from
django.core.files.storage
import
FileSystemStorage
from
django.core.urlresolvers
import
reverse_lazy
from
django.utils.encoding
import
force_text
from
.
import
appconfig
__all__
=
(
...
...
@@ -31,6 +33,11 @@ class PrivateStorage(FileSystemStorage):
# the attribute is overwritten here to avoid breaking lazy evaluation.
self
.
base_url
=
reverse_lazy
(
'serve_private_file'
,
kwargs
=
{
'path'
:
''
})
def
url
(
self
,
name
):
# Make sure reverse_lazy() is evaluated, as Python 3 won't do this here.
self
.
base_url
=
force_text
(
self
.
base_url
)
return
super
(
PrivateStorage
,
self
).
url
(
name
)
# Singleton instance.
private_storage
=
PrivateStorage
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment