summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Schwartz <wkschwartz@gmail.com>2020-12-30 11:49:58 -0600
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-05-14 20:45:04 +0200
commit1557778121e5d04a80f1f7c81eeb4b47400939e4 (patch)
treefd5e12a80aaad5df4ac7d3f7b4ea92ad2a21121d
parent1e655d35ad7540ea557c532ebc72a9acc407df50 (diff)
Refs #32317 -- Simplified find_fixtures() in loaddata command.
This always replaces 'fixture_name' with its base name, which preserves the previous behavior, because os.path.basename() was not called only on relative paths without os.path.sep i.e. when base name was equal to the file name. This also changes os.path.dirname() and os.path.basename() calls to the equivalent os.path.split() call.
-rw-r--r--django/core/management/commands/loaddata.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py
index 096d2c7aeb..021c6b7ee1 100644
--- a/django/core/management/commands/loaddata.py
+++ b/django/core/management/commands/loaddata.py
@@ -235,15 +235,14 @@ class Command(BaseCommand):
if self.verbosity >= 2:
self.stdout.write("Loading '%s' fixtures..." % fixture_name)
+ dirname, basename = os.path.split(fixture_name)
if os.path.isabs(fixture_name):
- fixture_dirs = [os.path.dirname(fixture_name)]
- fixture_name = os.path.basename(fixture_name)
+ fixture_dirs = [dirname]
else:
fixture_dirs = self.fixture_dirs
if os.path.sep in os.path.normpath(fixture_name):
- fixture_dirs = [os.path.join(dir_, os.path.dirname(fixture_name))
- for dir_ in fixture_dirs]
- fixture_name = os.path.basename(fixture_name)
+ fixture_dirs = [os.path.join(dir_, dirname) for dir_ in fixture_dirs]
+ fixture_name = basename
suffixes = (
'.'.join(ext for ext in combo if ext)