summaryrefslogtreecommitdiff
path: root/django/core/management/templates.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/core/management/templates.py')
-rw-r--r--django/core/management/templates.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/django/core/management/templates.py b/django/core/management/templates.py
index 623aa69deb..2bf2f661fd 100644
--- a/django/core/management/templates.py
+++ b/django/core/management/templates.py
@@ -8,7 +8,10 @@ import shutil
import stat
import sys
import tempfile
-import urllib
+try:
+ from urllib.request import urlretrieve
+except ImportError: # Python 2
+ from urllib import urlretrieve
from optparse import make_option
from os import path
@@ -227,8 +230,7 @@ class TemplateCommand(BaseCommand):
if self.verbosity >= 2:
self.stdout.write("Downloading %s\n" % display_url)
try:
- the_path, info = urllib.urlretrieve(url,
- path.join(tempdir, filename))
+ the_path, info = urlretrieve(url, path.join(tempdir, filename))
except IOError as e:
raise CommandError("couldn't download URL %s to %s: %s" %
(url, filename, e))