Django

Code

Changeset 7320

Show
Ignore:
Timestamp:
03/19/08 10:10:31 (4 months ago)
Author:
mtredinnick
Message:

Fixed #6789 -- Added some small amount of extra protection for learners trying
to pick a name for their project. Thanks, thejaswi_puthraya.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/management/commands/startproject.py

    r7294 r7320  
    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)