Ticket #6654: startproject-startapp.patch
File startproject-startapp.patch, 2.5 KB (added by , 17 years ago) |
---|
-
django/core/management/commands/startapp.py
23 23 if app_name == project_name: 24 24 raise CommandError("You cannot create an app with the same name" 25 25 " (%r) as your project." % app_name) 26 try: 27 __import__(app_name) 28 except ImportError: 29 pass 30 else: 31 raise CommandError("%r conflicts with the name of an existing" 32 " Python module and cannot be used as" 33 " an app name. Please try another name." 34 % project_name) 35 26 36 copy_helper(self.style, 'app', app_name, directory, project_name) 27 37 28 38 class ProjectCommand(Command): -
django/core/management/commands/startproject.py
3 3 import re 4 4 from random import choice 5 5 6 INVALID_PROJECT_NAMES = ('django', 'site', 'test')7 8 6 class Command(LabelCommand): 9 7 help = "Creates a Django project directory structure for the given project name in the current directory." 10 8 args = "[projectname]" … … 20 18 # the parent directory. 21 19 directory = os.getcwd() 22 20 21 # Check that the project_name is free and can't be imported 23 22 try: 24 proj_name = __import__(project_name) 25 if proj_name: 26 raise CommandError("%r conflicts with the name of an existing Python module and cannot be used as a project name. Please try another name." % project_name) 23 __import__(project_name) 27 24 except ImportError: 28 if project_name in INVALID_PROJECT_NAMES: 29 raise CommandError("%r contains an invalid project name. Please try another name." % project_name) 25 pass 26 else: 27 raise CommandError("%r conflicts with the name of an existing" 28 " Python module and cannot be used as" 29 " a project name. Please try another name." 30 % project_name) 30 31 31 32 copy_helper(self.style, 'project', project_name, directory) 32 33