diff --git a/django/core/management/commands/startapp.py b/django/core/management/commands/startapp.py
index 5581331..8c5d3ea 100644
|
a
|
b
|
from django.core.management.base import CommandError
|
| 2 | 2 | from django.core.management.templates import TemplateCommand |
| 3 | 3 | from django.utils.importlib import import_module |
| 4 | 4 | |
| | 5 | import os |
| | 6 | from os import path |
| | 7 | |
| 5 | 8 | |
| 6 | 9 | class Command(TemplateCommand): |
| 7 | 10 | help = ("Creates a Django app directory structure for the given app " |
| … |
… |
class Command(TemplateCommand):
|
| 21 | 24 | raise CommandError("%r conflicts with the name of an existing " |
| 22 | 25 | "Python module and cannot be used as an app " |
| 23 | 26 | "name. Please try another name." % app_name) |
| 24 | | |
| | 27 | |
| 25 | 28 | super(Command, self).handle('app', app_name, target, **options) |
| | 29 | |
| | 30 | def get_target_dir(self, target, name): |
| | 31 | top_dir = super(Command, self).get_target_dir(target, name) |
| | 32 | top_dir = os.path.abspath(path.expanduser(target)) |
| | 33 | top_dir = os.path.join(top_dir, name) |
| | 34 | |
| | 35 | if not os.path.exists(top_dir): |
| | 36 | os.mkdir(top_dir) |
| | 37 | |
| | 38 | return top_dir |
diff --git a/django/core/management/templates.py b/django/core/management/templates.py
index 623aa69..5e81588 100644
|
a
|
b
|
class TemplateCommand(BaseCommand):
|
| 59 | 59 | # The supported URL schemes |
| 60 | 60 | url_schemes = ['http', 'https', 'ftp'] |
| 61 | 61 | |
| | 62 | def get_target_dir(self, target, name): |
| | 63 | """ |
| | 64 | Creates a directory for when location of the app or project |
| | 65 | are specified. |
| | 66 | """ |
| | 67 | top_dir = os.path.abspath(path.expanduser(target)) |
| | 68 | if not os.path.exists(top_dir): |
| | 69 | raise CommandError("Destination directory '%s' does not " |
| | 70 | "exist, please create it first." % top_dir) |
| | 71 | |
| | 72 | return top_dir |
| | 73 | |
| | 74 | |
| 62 | 75 | def handle(self, app_or_project, name, target=None, **options): |
| 63 | 76 | self.app_or_project = app_or_project |
| 64 | 77 | self.paths_to_remove = [] |
| … |
… |
class TemplateCommand(BaseCommand):
|
| 87 | 100 | message = e |
| 88 | 101 | raise CommandError(message) |
| 89 | 102 | else: |
| 90 | | top_dir = os.path.abspath(path.expanduser(target)) |
| 91 | | if not os.path.exists(top_dir): |
| 92 | | raise CommandError("Destination directory '%s' does not " |
| 93 | | "exist, please create it first." % top_dir) |
| | 103 | top_dir = self.get_target_dir(target, name) |
| | 104 | |
| 94 | 105 | |
| 95 | 106 | extensions = tuple( |
| 96 | 107 | handle_extensions(options.get('extensions'), ignored=())) |
| … |
… |
class TemplateCommand(BaseCommand):
|
| 141 | 152 | # Ignore some files as they cause various breakages. |
| 142 | 153 | continue |
| 143 | 154 | old_path = path.join(root, filename) |
| | 155 | |
| 144 | 156 | new_path = path.join(top_dir, relative_dir, |
| 145 | 157 | filename.replace(base_name, name)) |
| 146 | 158 | if path.exists(new_path): |