diff --git a/django/contrib/staticfiles/management/commands/collectstatic.py b/django/contrib/staticfiles/management/commands/collectstatic.py index 8882ae20db..10f9fdd016 100644 --- a/django/contrib/staticfiles/management/commands/collectstatic.py +++ b/django/contrib/staticfiles/management/commands/collectstatic.py @@ -100,7 +100,7 @@ Type 'yes' to continue, or 'no' to cancel: """) except (OSError, NotImplementedError): source_last_modified = None if prefix: - destination = '/'.join([prefix, source]) + destination = os.path.join(prefix, source) else: destination = source symlink = options['link'] diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py index eb0eabf861..56e5c0dec0 100644 --- a/django/contrib/staticfiles/storage.py +++ b/django/contrib/staticfiles/storage.py @@ -82,6 +82,6 @@ class AppStaticStorage(FileSystemStorage): prefix = self.get_prefix() for path in utils.get_files(self, ignore_patterns): if prefix: - path = '/'.join([prefix, path]) + path = os.path.join(prefix, path) files.append(path) return files diff --git a/django/contrib/staticfiles/utils.py b/django/contrib/staticfiles/utils.py index 428bb69b1e..187a6d3429 100644 --- a/django/contrib/staticfiles/utils.py +++ b/django/contrib/staticfiles/utils.py @@ -1,18 +1,17 @@ +import os import fnmatch from django.conf import settings from django.core.exceptions import ImproperlyConfigured def get_files(storage, ignore_patterns=[], location=''): """ - Recursively walk the storage directories gathering a complete list of files - that should be copied, returning this list. - + Recursively walk the storage directories gathering a complete + list of files that should be copied, returning this list. """ def is_ignored(path): """ Return True or False depending on whether the ``path`` should be ignored (if it matches any pattern in ``ignore_patterns``). - """ for pattern in ignore_patterns: if fnmatch.fnmatchcase(path, pattern): @@ -20,14 +19,14 @@ def get_files(storage, ignore_patterns=[], location=''): return False directories, files = storage.listdir(location) - static_files = [location and '/'.join([location, fn]) or fn + static_files = [location and os.path.join(location, fn) or fn for fn in files if not is_ignored(fn)] for dir in directories: if is_ignored(dir): continue if location: - dir = '/'.join([location, dir]) + dir = os.path.join(location, dir) static_files.extend(get_files(storage, ignore_patterns, dir)) return static_files