mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Made sure startproject can handle template URLs with trailing slashes.
Thanks Issac Kelly that reported this via IRC. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17320 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -196,13 +196,22 @@ class TemplateCommand(BaseCommand):
|
||||
"""
|
||||
Downloads the given URL and returns the file name.
|
||||
"""
|
||||
def cleanup_url(url):
|
||||
tmp = url.rstrip('/')
|
||||
filename = tmp.split('/')[-1]
|
||||
if url.endswith('/'):
|
||||
display_url = tmp + '/'
|
||||
else:
|
||||
display_url = url
|
||||
return filename, display_url
|
||||
|
||||
prefix = 'django_%s_template_' % self.app_or_project
|
||||
tempdir = tempfile.mkdtemp(prefix=prefix, suffix='_download')
|
||||
self.paths_to_remove.append(tempdir)
|
||||
filename = url.split('/')[-1]
|
||||
filename, display_url = cleanup_url(url)
|
||||
|
||||
if self.verbosity >= 2:
|
||||
self.stdout.write("Downloading %s\n" % url)
|
||||
self.stdout.write("Downloading %s\n" % display_url)
|
||||
try:
|
||||
the_path, info = urllib.urlretrieve(url,
|
||||
path.join(tempdir, filename))
|
||||
|
||||
Reference in New Issue
Block a user