Django

Code

Ticket #6789: 6789.diff

File 6789.diff, 1.1 kB (added by thejaswi_puthraya, 8 months ago)

diff for the ticket #6789

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

    old new  
    2020        # the parent directory. 
    2121        directory = os.getcwd() 
    2222 
    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) 
     23        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) 
     27        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) 
    2530 
    2631        copy_helper(self.style, 'project', project_name, directory) 
    2732