def startproject(project_name, directory):
 from random import choice
 if (project_name in INVALID_PROJECT_NAMES):
  sys.stderr.write(style.ERROR(("Error: '%r' conflicts with the name of an existing Python module and cannot be used as a project name. Please try another name.\n" % project_name)))
  sys.exit(1)
 _start_helper('project', project_name, directory)
 main_settings_file = os.path.join(directory, project_name, 'settings.py')
 settings_contents = open(main_settings_file, 'r').read()
 fp = open(main_settings_file, 'w')
 secret_key = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)])
 settings_contents = re.sub("(?<=SECRET_KEY = ')'", (secret_key + "'"), settings_contents)
 fp.write(settings_contents)
 fp.close()

def startproject ( project_name , directory ) : from random import choice if ( project_name in INVALID_PROJECT_NAMES ) : sys . stderr . write ( style . ERROR ( ( "Error: '%r' conflicts with the name of an existing Python module and cannot be used as a project name. Please try another name.\n" % project_name ) ) ) sys . exit ( 1 ) _start_helper ( 'project' , project_name , directory ) main_settings_file = os . path . join ( directory , project_name , 'settings.py' ) settings_contents = open ( main_settings_file , 'r' ) . read ( ) fp = open ( main_settings_file , 'w' ) secret_key = '' . join ( [ choice ( 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)' ) for i in range ( 50 ) ] ) settings_contents = re . sub ( "(?<=SECRET_KEY = ')'" , ( secret_key + "'" ) , settings_contents ) fp . write ( settings_contents ) fp . close ( )
creates a django project for the given project_name in the given directory .