Commit 0e9c2fea authored by Diederik van der Boor's avatar Diederik van der Boor
Browse files

Fix url reversing in Python 3

parent f3e7e6d4
...@@ -3,6 +3,8 @@ Django Storage interface ...@@ -3,6 +3,8 @@ Django Storage interface
""" """
from django.core.files.storage import FileSystemStorage from django.core.files.storage import FileSystemStorage
from django.core.urlresolvers import reverse_lazy from django.core.urlresolvers import reverse_lazy
from django.utils.encoding import force_text
from . import appconfig from . import appconfig
__all__ = ( __all__ = (
...@@ -31,6 +33,11 @@ class PrivateStorage(FileSystemStorage): ...@@ -31,6 +33,11 @@ class PrivateStorage(FileSystemStorage):
# the attribute is overwritten here to avoid breaking lazy evaluation. # the attribute is overwritten here to avoid breaking lazy evaluation.
self.base_url = reverse_lazy('serve_private_file', kwargs={'path': ''}) 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. # Singleton instance.
private_storage = PrivateStorage() private_storage = PrivateStorage()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment