We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
"wagtail start project_name" fails to run on Windows 7
Hi. So everything is compiled perfectly inside the virtualenv and I'm trying to start a new project.

```
$ wagtail start wagtailtest
Creating a wagtail project called wagtailtest
Traceback (most recent call last):
  File "d:\VirtualEnvs\wagtail_env\Scripts\wagtail-script.py", line 9, in <module>
    load_entry_point('wagtail==0.6', 'console_scripts', 'wagtail')()
  File "d:\VirtualEnvs\wagtail_env\lib\site-packages\wagtail\bin\wagtail.py", line 75, in main
    COMMANDS[command](parser, options, args)
  File "d:\VirtualEnvs\wagtail_env\lib\site-packages\wagtail\bin\wagtail.py", line 51, in create_project
    project_name
  File "C:\Python27\Lib\subprocess.py", line 522, in call
    return Popen(*popenargs, **kwargs).wait()
  File "C:\Python27\Lib\subprocess.py", line 710, in __init__
    errread, errwrite)
  File "C:\Python27\Lib\subprocess.py", line 958, in _execute_child
    startupinfo)
WindowsError: [Error 193] %1 is not a valid Win32 application
```

Windows 7 x64, Python 2.7 x32.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `wagtail/bin/wagtail.py`
Content:
```
1 #!/usr/bin/env python
2 from __future__ import print_function, absolute_import
3 
4 import os
5 import subprocess
6 import errno
7 import sys
8 
9 from optparse import OptionParser
10 
11 
12 def create_project(parser, options, args):
13     # Validate args
14     if len(args) < 2:
15         parser.error("Please specify a name for your wagtail installation")
16     elif len(args) > 2:
17         parser.error("Too many arguments")
18 
19     project_name = args[1]
20 
21     # Make sure given name is not already in use by another python package/module.
22     try:
23         __import__(project_name)
24     except ImportError:
25         pass
26     else:
27         parser.error("'%s' conflicts with the name of an existing "
28                      "Python module and cannot be used as a project "
29                      "name. Please try another name." % project_name)
30 
31     # Make sure directory does not already exist
32     if os.path.exists(project_name):
33         print('A directory called %(project_name)s already exists. \
34             Please choose another name for your wagtail project or remove the existing directory.' % {'project_name': project_name})
35         sys.exit(errno.EEXIST)
36 
37     print("Creating a wagtail project called %(project_name)s" % {'project_name': project_name})
38 
39     # Create the project from the wagtail template using startapp
40 
41     # First find the path to wagtail
42     import wagtail
43     wagtail_path = os.path.dirname(wagtail.__file__)
44     template_path = os.path.join(wagtail_path, 'project_template')
45 
46     # Call django-admin startproject
47     result = subprocess.call([
48         'django-admin.py', 'startproject',
49         '--template=' + template_path,
50         '--name=Vagrantfile', '--ext=html,rst',
51         project_name
52     ])
53 
54     if result == 0:
55         print("Success! %(project_name)s is created" % {'project_name': project_name})
56 
57 
58 COMMANDS = {
59     'start': create_project,
60 }
61 
62 def main():
63     # Parse options
64     parser = OptionParser(usage="Usage: %prog start project_name")
65     (options, args) = parser.parse_args()
66 
67     # Find command
68     try:
69         command = args[0]
70     except IndexError:
71         parser.print_help()
72         return
73 
74     if command in COMMANDS:
75         COMMANDS[command](parser, options, args)
76     else:
77         parser.error("Unrecognised command: " + command)
78 
79 if __name__ == "__main__":
80     main()
81
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/wagtail/bin/wagtail.py b/wagtail/bin/wagtail.py
--- a/wagtail/bin/wagtail.py
+++ b/wagtail/bin/wagtail.py
@@ -2,11 +2,11 @@
 from __future__ import print_function, absolute_import
 
 import os
-import subprocess
 import errno
 import sys
 
 from optparse import OptionParser
+from django.core.management import ManagementUtility
 
 
 def create_project(parser, options, args):
@@ -44,15 +44,15 @@
     template_path = os.path.join(wagtail_path, 'project_template')
 
     # Call django-admin startproject
-    result = subprocess.call([
+    utility = ManagementUtility([
         'django-admin.py', 'startproject',
         '--template=' + template_path,
         '--name=Vagrantfile', '--ext=html,rst',
         project_name
     ])
+    utility.execute()
 
-    if result == 0:
-        print("Success! %(project_name)s is created" % {'project_name': project_name})
+    print("Success! %(project_name)s is created" % {'project_name': project_name})
 
 
 COMMANDS = {

{"golden_diff": "diff --git a/wagtail/bin/wagtail.py b/wagtail/bin/wagtail.py\n--- a/wagtail/bin/wagtail.py\n+++ b/wagtail/bin/wagtail.py\n@@ -2,11 +2,11 @@\n from __future__ import print_function, absolute_import\n \n import os\n-import subprocess\n import errno\n import sys\n \n from optparse import OptionParser\n+from django.core.management import ManagementUtility\n \n \n def create_project(parser, options, args):\n@@ -44,15 +44,15 @@\n     template_path = os.path.join(wagtail_path, 'project_template')\n \n     # Call django-admin startproject\n-    result = subprocess.call([\n+    utility = ManagementUtility([\n         'django-admin.py', 'startproject',\n         '--template=' + template_path,\n         '--name=Vagrantfile', '--ext=html,rst',\n         project_name\n     ])\n+    utility.execute()\n \n-    if result == 0:\n-        print(\"Success! %(project_name)s is created\" % {'project_name': project_name})\n+    print(\"Success! %(project_name)s is created\" % {'project_name': project_name})\n \n \n COMMANDS = {\n", "issue": "\"wagtail start project_name\" fails to run on Windows 7\nHi. So everything is compiled perfectly inside the virtualenv and I'm trying to start a new project.\n\n```\n$ wagtail start wagtailtest\nCreating a wagtail project called wagtailtest\nTraceback (most recent call last):\n  File \"d:\\VirtualEnvs\\wagtail_env\\Scripts\\wagtail-script.py\", line 9, in <module>\n    load_entry_point('wagtail==0.6', 'console_scripts', 'wagtail')()\n  File \"d:\\VirtualEnvs\\wagtail_env\\lib\\site-packages\\wagtail\\bin\\wagtail.py\", line 75, in main\n    COMMANDS[command](parser, options, args)\n  File \"d:\\VirtualEnvs\\wagtail_env\\lib\\site-packages\\wagtail\\bin\\wagtail.py\", line 51, in create_project\n    project_name\n  File \"C:\\Python27\\Lib\\subprocess.py\", line 522, in call\n    return Popen(*popenargs, **kwargs).wait()\n  File \"C:\\Python27\\Lib\\subprocess.py\", line 710, in __init__\n    errread, errwrite)\n  File \"C:\\Python27\\Lib\\subprocess.py\", line 958, in _execute_child\n    startupinfo)\nWindowsError: [Error 193] %1 is not a valid Win32 application\n```\n\nWindows 7 x64, Python 2.7 x32.\n\n", "before_files": [{"content": "#!/usr/bin/env python\nfrom __future__ import print_function, absolute_import\n\nimport os\nimport subprocess\nimport errno\nimport sys\n\nfrom optparse import OptionParser\n\n\ndef create_project(parser, options, args):\n    # Validate args\n    if len(args) < 2:\n        parser.error(\"Please specify a name for your wagtail installation\")\n    elif len(args) > 2:\n        parser.error(\"Too many arguments\")\n\n    project_name = args[1]\n\n    # Make sure given name is not already in use by another python package/module.\n    try:\n        __import__(project_name)\n    except ImportError:\n        pass\n    else:\n        parser.error(\"'%s' conflicts with the name of an existing \"\n                     \"Python module and cannot be used as a project \"\n                     \"name. Please try another name.\" % project_name)\n\n    # Make sure directory does not already exist\n    if os.path.exists(project_name):\n        print('A directory called %(project_name)s already exists. \\\n            Please choose another name for your wagtail project or remove the existing directory.' % {'project_name': project_name})\n        sys.exit(errno.EEXIST)\n\n    print(\"Creating a wagtail project called %(project_name)s\" % {'project_name': project_name})\n\n    # Create the project from the wagtail template using startapp\n\n    # First find the path to wagtail\n    import wagtail\n    wagtail_path = os.path.dirname(wagtail.__file__)\n    template_path = os.path.join(wagtail_path, 'project_template')\n\n    # Call django-admin startproject\n    result = subprocess.call([\n        'django-admin.py', 'startproject',\n        '--template=' + template_path,\n        '--name=Vagrantfile', '--ext=html,rst',\n        project_name\n    ])\n\n    if result == 0:\n        print(\"Success! %(project_name)s is created\" % {'project_name': project_name})\n\n\nCOMMANDS = {\n    'start': create_project,\n}\n\ndef main():\n    # Parse options\n    parser = OptionParser(usage=\"Usage: %prog start project_name\")\n    (options, args) = parser.parse_args()\n\n    # Find command\n    try:\n        command = args[0]\n    except IndexError:\n        parser.print_help()\n        return\n\n    if command in COMMANDS:\n        COMMANDS[command](parser, options, args)\n    else:\n        parser.error(\"Unrecognised command: \" + command)\n\nif __name__ == \"__main__\":\n    main()\n", "path": "wagtail/bin/wagtail.py"}], "after_files": [{"content": "#!/usr/bin/env python\nfrom __future__ import print_function, absolute_import\n\nimport os\nimport errno\nimport sys\n\nfrom optparse import OptionParser\nfrom django.core.management import ManagementUtility\n\n\ndef create_project(parser, options, args):\n    # Validate args\n    if len(args) < 2:\n        parser.error(\"Please specify a name for your wagtail installation\")\n    elif len(args) > 2:\n        parser.error(\"Too many arguments\")\n\n    project_name = args[1]\n\n    # Make sure given name is not already in use by another python package/module.\n    try:\n        __import__(project_name)\n    except ImportError:\n        pass\n    else:\n        parser.error(\"'%s' conflicts with the name of an existing \"\n                     \"Python module and cannot be used as a project \"\n                     \"name. Please try another name.\" % project_name)\n\n    # Make sure directory does not already exist\n    if os.path.exists(project_name):\n        print('A directory called %(project_name)s already exists. \\\n            Please choose another name for your wagtail project or remove the existing directory.' % {'project_name': project_name})\n        sys.exit(errno.EEXIST)\n\n    print(\"Creating a wagtail project called %(project_name)s\" % {'project_name': project_name})\n\n    # Create the project from the wagtail template using startapp\n\n    # First find the path to wagtail\n    import wagtail\n    wagtail_path = os.path.dirname(wagtail.__file__)\n    template_path = os.path.join(wagtail_path, 'project_template')\n\n    # Call django-admin startproject\n    utility = ManagementUtility([\n        'django-admin.py', 'startproject',\n        '--template=' + template_path,\n        '--name=Vagrantfile', '--ext=html,rst',\n        project_name\n    ])\n    utility.execute()\n\n    print(\"Success! %(project_name)s is created\" % {'project_name': project_name})\n\n\nCOMMANDS = {\n    'start': create_project,\n}\n\ndef main():\n    # Parse options\n    parser = OptionParser(usage=\"Usage: %prog start project_name\")\n    (options, args) = parser.parse_args()\n\n    # Find command\n    try:\n        command = args[0]\n    except IndexError:\n        parser.print_help()\n        return\n\n    if command in COMMANDS:\n        COMMANDS[command](parser, options, args)\n    else:\n        parser.error(\"Unrecognised command: \" + command)\n\nif __name__ == \"__main__\":\n    main()\n", "path": "wagtail/bin/wagtail.py"}]}