1
0
mirror of https://github.com/django/django.git synced 2025-10-28 08:06:09 +00:00

Fixed #18296 -- Created missing custom target directory for startproject and startapp.

This commit is contained in:
Bruno Alla
2025-04-27 12:01:24 +02:00
committed by Sarah Boyce
parent 3babda775d
commit bc21bc4282
5 changed files with 92 additions and 30 deletions

View File

@@ -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.