Skip to content

Commit b77c508

Browse files
author
Buky
authored
Merge pull request #725 from vmsp/fix-714
Add Django 3.1 compatibility
2 parents ce19344 + 037914d commit b77c508

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

pipeline/storage.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
from io import BytesIO
44

5-
from django.contrib.staticfiles.storage import CachedStaticFilesStorage, ManifestStaticFilesStorage, StaticFilesStorage
5+
import django
6+
7+
_CACHED_STATIC_FILES_STORAGE_AVAILABLE = django.VERSION[0] <= 3 and django.VERSION[1] < 1
8+
9+
if _CACHED_STATIC_FILES_STORAGE_AVAILABLE:
10+
from django.contrib.staticfiles.storage import CachedStaticFilesStorage
11+
from django.contrib.staticfiles.storage import ManifestStaticFilesStorage, StaticFilesStorage
612
from django.contrib.staticfiles.utils import matches_patterns
713

814
from django.core.files.base import File
@@ -90,14 +96,17 @@ class NonPackagingPipelineStorage(NonPackagingMixin, PipelineStorage):
9096
pass
9197

9298

93-
class PipelineCachedStorage(PipelineMixin, CachedStaticFilesStorage):
94-
# Deprecated since Django 2.2
95-
pass
99+
if _CACHED_STATIC_FILES_STORAGE_AVAILABLE:
100+
class PipelineCachedStorage(PipelineMixin, CachedStaticFilesStorage):
101+
# Deprecated since Django 2.2
102+
# Removed in Django 3.1
103+
pass
96104

97105

98-
class NonPackagingPipelineCachedStorage(NonPackagingMixin, PipelineCachedStorage):
99-
# Deprecated since Django 2.2
100-
pass
106+
class NonPackagingPipelineCachedStorage(NonPackagingMixin, PipelineCachedStorage):
107+
# Deprecated since Django 2.2
108+
# Removed in Django 3.1
109+
pass
101110

102111

103112
class PipelineManifestStorage(PipelineMixin, ManifestStaticFilesStorage):

pipeline/templatetags/pipeline.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
from django.contrib.staticfiles.storage import staticfiles_storage
55

66
from django import template
7-
from django.template.base import Context, VariableDoesNotExist
7+
from django.template.context import Context
8+
from django.template.base import VariableDoesNotExist
89
from django.template.loader import render_to_string
910
from django.utils.safestring import mark_safe
1011

0 commit comments

Comments
 (0)