-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew.py
29 lines (22 loc) · 1.03 KB
/
new.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from django.core.management import BaseCommand
from django.core.management import call_command
from ...conf import TEMPLATES_DIR
PROJECT_STRUCTURE_MAP = {
"1": f"{TEMPLATES_DIR}/default",
"2": f"{TEMPLATES_DIR}/single_file",
"3": f"{TEMPLATES_DIR}/classic",
}
class Command(BaseCommand):
help = "Create a new Django project."
def add_arguments(self, parser):
parser.add_argument("project_name", type=str)
def handle(self, *args, **options):
project_name = options["project_name"]
self.stdout.write("Which type of project would you like to create?")
self.stdout.write("1: Quick start Django project")
self.stdout.write("2: Single file project")
self.stdout.write("3: A classic project")
self.stdout.write("You may also enter a path or URL to a custom template")
project_structure = input()
project_template = PROJECT_STRUCTURE_MAP.get(project_structure, project_structure)
call_command("startproject", project_name, template=project_template)