Changes between Version 30 and Version 31 of DjangoOnWindowsWithIISAndSQLServer
- Timestamp:
- Jan 11, 2008, 6:25:19 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DjangoOnWindowsWithIISAndSQLServer
v30 v31 2 2 Getting Django to run on Windows, with pages served by IIS, and a SQL Server backend. Assume Windows Server 2003, IIS 6 and SQL Server 2005 where no versions are specified. You should already have Windows, IIS and SQL installed and working before following this guide. 3 3 4 ''' ''Note:''' This doesn't work with Django <=0.91 as the IIS extenstion is written to the APIs in Django >=0.92 [SF]''4 '''Note''': As of PyISAPIe version 1.0.4, this works with Python 2.5. The provided handler works with the current (1-11-08) CVS version of Django. 5 5 6 '''Note2''': This doesn't work with Python 2.5. It must (for some reason) be Python 2.46 '''Note2''': PyISAPIe also provides a WSGI adapter that may work with earlier versions of Django. Refer to the new release and docs: http://pyisapie.sourceforge.net/ 7 7 8 8 === Steps === … … 26 26 Now on with the setup: Go to http://pyisapie.sourceforge.net/ and download it (look in the menu on the right, under "Links" for a download link). Unzip the archive so you can copy files out of it. 27 27 28 I will assume you've extracted it to c:\pyisapie, and are using c:\python2 4as the folder where Python is installed, but please change these where necessary for your setup.28 I will assume you've extracted it to c:\pyisapie, and are using c:\python25 as the folder where Python is installed, but please change these where necessary for your setup. 29 29 30 30 There is documentation in the readme files, but at the time of writing the install consists of: 31 31 32 32 === Setting up Files === 33 * Copy c:\pyisapie\PyISAPIe.dll to c:\python2 4\33 * Copy c:\pyisapie\PyISAPIe.dll to c:\python25\ 34 34 * Edit the properties -> security settings on that file, add "Network Service" and tick "read" permission. (So IIS can use it). 35 * Go to c:\pyisapie\source\PyISAPIe\Python\ and copy the entire Http folder to c:\python2 4\lib\site-packages. '''''Note:''' the Http folder is case sensitive. Saving in 'http' (or any other variation) will not work [SF]''.35 * Go to c:\pyisapie\source\PyISAPIe\Python\ and copy the entire Http folder to c:\python25\lib\site-packages. '''''Note:''' the Http folder is case sensitive. Saving in 'http' (or any other variation) will not work [SF]''. 36 36 37 37 === Setting up IIS === … … 55 55 * For Executable, browse to pyisapie.dll (needs full path if you enter manually) 56 56 * For extension enter ''*'' (this will redirect all requests to pyisapi) 57 * ''Using star DOES NOT work in IIS 5, you must specify an extension. [pjs]'' 57 58 * ''You should probably limit the verbs allowed; I left as ''all'' since it was for internal use.'' 58 59 * Untick the "check that file exists" box. … … 63 64 64 65 == Django == 65 '''Please note that as of March 7th, 2007, the below instructions will not work for the latest development versions of Django. In order for PyISAPIe to work with Django (and vice versa), you must be using Django v. 0.95. Versions 0.95.1 and any higher produce numerous errors that seem to be related to PyISAPIe's stalled development. Thankfully, you can still download version 0.95 from the Django download site.'''66 67 66 '''Text below saved in hope of an update to PyISAPIe:'''[[BR]] 68 67 ''If you want to keep up with the latest Django development version, you will need to download and install a subversion client for Windows, e.g. [http://tortoisesvn.tigris.org/ Tortoise SVN], install it, then create a new folder somewhere. Right click on the folder, and choose "SVN Checkout". Give the URL of the repository as: http://code.djangoproject.com/svn/django/trunk/ and click OK.)'' 69 68 70 ''Otherwise, just download the latest Django release from the main site, and extract the archive to a folder, e.g. c:\python2 4\django\.''69 ''Otherwise, just download the latest Django release from the main site, and extract the archive to a folder, e.g. c:\python25\django\.'' 71 70 72 71 === Installing Django === … … 74 73 75 74 {{{ 76 c:\> cd python2 4\django77 c:\python2 4\django> python setup.py install75 c:\> cd python25\django 76 c:\python25\django> python setup.py install 78 77 }}} 79 78 … … 83 82 c:\> md test 84 83 c:\> cd test 85 c:\test> d:\Python2 4\django\django\bin\django-admin.py startproject proj84 c:\test> d:\Python25\django\django\bin\django-admin.py startproject proj 86 85 87 86 c:\test> cd proj … … 99 98 100 99 === Linking Django to PyISAPIe === 100 101 101 Next, you must follow the readme.txt in the PyISAPIe examples\django folder, basically copy two files into specific folders. Then edit them a bit in order to fit your needs. 102 102 103 * Put Isapi.py in c:\python2 4\lib\site-packages\Http folder. According to the example given above, you'll make the following changes to it:103 * Put Isapi.py in c:\python25\lib\site-packages\Http folder. According to the example given above, you'll make the following changes to it: 104 104 105 105 {{{ … … 112 112 }}} 113 113 114 * Put pyisapie.py in c:\python24\lib\site-packages\Django-xyz-123.egg\django\core\handlers folder. But there's a bug in PyISAPIe v1.0.3 that prevent it from working (hopefully they'll fix it in the next release). What you have to do is to add a single line of code to the pyisapie.py file you just copied: 115 116 {{{ 117 # ...some stuff ahead 118 119 class PyISAPIeRequest(http.HttpRequest): 120 def __init__(This): 121 # ADD THIS LINE! 122 This.method = Env.REQUEST_METHOD 123 124 # ...and don't need to change the rest 125 126 # some stuff behind... 127 }}} 128 114 * Put pyisapie.py in c:\python25\lib\site-packages\Django-xyz-123.egg\django\core\handlers folder. 129 115 * It doesn't seem that ''IIS+Python+PyISAPIe'' support multiple Django sites. 116 * ''This is related to the impossibility of having multiple values for DJANGO_SETTINGS_MODULE in os.environ within a single IIS worker process. Can said value be specified in the request env? [pjs]'' 130 117 131 118 === Serving Django with IIS === … … 160 147 == Known Issues == 161 148 * On IIS 5, you have to use the console command "iisreset" for code changes to take effect. Just restarting the website in ''IIS Management Console'' has no use. How about IIS 6? (20070304/henrik: - same for iis6 on win2k3) 149 * ''NOT true for IIS6: right-click on the application pool your site is using and select "Recycle." [pjs]'' 162 150 * ''I had to create a "media" virtual directory for the stylesheets, etc, at the root of my IIS directory tree (urgh) with read permissions to get the admin site to load styles. Looking at the source for the admin page in my browser, the stylesheet link is absolute (/media/...) [rnm]'' 163 151 == Install the PyWin32 Extensions == … … 167 155 Go to the homepage, which is http://adodbapi.sourceforge.net/ then follow the link to download the latest version. 168 156 169 Then extract the zip file somewhere, e.g. c:\python2 4\adodbapi, and run 'setup.bat' from that folder.157 Then extract the zip file somewhere, e.g. c:\python25\adodbapi, and run 'setup.bat' from that folder. 170 158 171 159 == Configure Django to look at SQL Server ==