diff options
| author | Bruno Alla <alla.brunoo@gmail.com> | 2025-04-27 12:01:24 +0200 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-04-27 14:41:27 +0100 |
| commit | bc21bc4282d854053c1218e8fb3ea39387ccca72 (patch) | |
| tree | 548330c1779ad6049aa8389c6456b628c657e276 /django | |
| parent | 3babda775d822232c8438dba8206cd2f3e2dfacc (diff) | |
Fixed #18296 -- Created missing custom target directory for startproject and startapp.
Diffstat (limited to 'django')
| -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. |
