Running a Django Application on IIS
Overview
How to get a Django project hosted on an IIS server. N.B that this article was originally created April 2013. The information in it will probably become outdated very quickly.
Prerequisites
- Install Python 2.7 from the main distribution found after searching for "Windows python"
- Install
pip(These installers worked well) - Install Django using pip:
pip install django
Trying to use the BitNami Django Stack caused ImportExport errors when runningpython manage.py collectstatic: "no django.core.management module".) - pywin32 - Python extensions for Windows
- django-windows-tools
Instructions
Geek Quickies: Running Django Under Windows With IIS Using FastCGI
Setting up a virtualenv under Windows
All that's necessary is the instructions above. This section about setting up a virtualenv was a path that I started down but ultimately wasn't applied. Leaving this information here just in case it would be of use in the future.
- Running the command
virtualenv my-proj-env --no-site-packagesI was running into this error:
- Running the command
AssertionError: Filename c:\Python27\Lib\os.py does not start with any of these prefixes: ['c:\\python27']
- There were two useful bits of advice in the Stackoverflow thread:
- The path values stored in the
PYTHONPATHenvironment variable need to match the case of the path at the end of the error message.
In my case both the drive letter and the "p" in "python" were lowercase and all the paths needed to match, i.e. both the "c" and "p" needed to be lowercase even though the directory name was actually capitalized. - Once that error was resolved, I got the following
- The path values stored in the
ImportError: No module named _socket
- Which was resolved by adding "c:\python27\DLLs" to the
PYTHONPATHenvironment variable.
- Which was resolved by adding "c:\python27\DLLs" to the