diff options
Diffstat (limited to 'django/core')
| -rw-r--r-- | django/core/management/templates.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/django/core/management/templates.py b/django/core/management/templates.py index dbaea11200..ea2c4a294f 100644 --- a/django/core/management/templates.py +++ b/django/core/management/templates.py @@ -46,7 +46,9 @@ class TemplateCommand(BaseCommand): def add_arguments(self, parser): parser.add_argument("name", help="Name of the application or project.") parser.add_argument( - "directory", nargs="?", help="Optional destination directory" + "directory", + nargs="?", + help="Optional destination directory, this will be created if needed.", ) parser.add_argument( "--template", help="The path or URL to load the template from." @@ -105,10 +107,10 @@ class TemplateCommand(BaseCommand): if app_or_project == "app": self.validate_name(os.path.basename(top_dir), "directory") if not os.path.exists(top_dir): - raise CommandError( - "Destination directory '%s' does not " - "exist, please create it first." % top_dir - ) + try: + os.makedirs(top_dir) + except OSError as e: + raise CommandError(e) # Find formatters, which are external executables, before input # from the templates can sneak into the path. |
