summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-12-01 02:20:59 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-12-01 02:20:59 +0000
commit153b5a4a3aee057445b255ea387cd93dac2e5786 (patch)
tree9e3da80c6d40661d427f09af502e9d62f80331f7
parent8e68fc6cd1e2d9620f267c1dd6d9c73650c14b5e (diff)
Fixed #9723 -- Not all Python distributions contain the bz2 module, so we need to allow for that. Based on a patch from AdamG.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9537 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/management/commands/loaddata.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py
index f3d8d26cd3..15c5e0998b 100644
--- a/django/core/management/commands/loaddata.py
+++ b/django/core/management/commands/loaddata.py
@@ -10,6 +10,12 @@ try:
except NameError:
from sets import Set as set # Python 2.3 fallback
+try:
+ import bz2
+ has_bz2 = True
+except ImportError:
+ has_bz2 = False
+
class Command(BaseCommand):
help = 'Installs the named fixture(s) in the database.'
args = "fixture [fixture ...]"
@@ -62,10 +68,11 @@ class Command(BaseCommand):
compression_types = {
None: file,
- 'bz2': bz2.BZ2File,
'gz': gzip.GzipFile,
'zip': SingleZipReader
}
+ if has_bz2:
+ compression_types['bz2'] = bz2.BZ2File
app_fixtures = [os.path.join(os.path.dirname(app.__file__), 'fixtures') for app in get_apps()]
for fixture_label in fixture_labels: