Ticket #6654: startproject.patch

File startproject.patch, 1.3 KB (added by Ivan Illarionov, 16 years ago)

startproject command fix

  • django/core/management/commands/startproject.py

     
    33import re
    44from random import choice
    55
    6 INVALID_PROJECT_NAMES = ('django', 'site', 'test')
    7 
    86class Command(LabelCommand):
    97    help = "Creates a Django project directory structure for the given project name in the current directory."
    108    args = "[projectname]"
     
    2018        # the parent directory.
    2119        directory = os.getcwd()
    2220
    23         if project_name in INVALID_PROJECT_NAMES:
    24             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)
     21        # Check that the project_name is free and can't be imported
     22        try:
     23            __import__(project_name)
     24        except:
     25            pass
     26        else:
     27            raise CommandError("%r conflicts with the name of an existing "
     28                "Python module and cannot be used as a project name. "
     29                "Please try another name." % project_name)
    2530
    2631        copy_helper(self.style, 'project', project_name, directory)
    2732
Back to Top