Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up Django on IIS

I have been trying to setup Django to work on IIS 7 Enterprise (Version 6.1 on Windows 7), but so far have been unable to. I am using Django 1.8.3 and Python 2.7. I am using PyISAPI to run Django on IIS. I have tried both the 2.6 version of PyISAPI and the 2.7 version (http://blog.wolfplusplus.com/?attachment_id=276). I have followed the following tutorials:

IIS Not Linking to Django with PyISAPIe

http://blog.wolfplusplus.com/?p=272

I have followed others also, and all of them do slightly different things. None of them have worked with me so far, and all of the tutorials seems to be a couple of years old. Can someone provide a straightforward up to date guide on how to setup Django 1.8 (running with Python 2.7) with IIS. There seems to be multiple approaches such as using FastCGI, but I have read that PyISAPI is much faster than FastCGI. My goal is to run a Django application on IIS.

like image 362
abden003 Avatar asked Jul 17 '15 07:07

abden003


People also ask

Can you run Django on IIS?

Django is a framework which has its own URL routing, so Django apps must be installed as a “handler” in IIS for specific paths. To install a Django app on the IIS's Default Web Site, select it in the management console, and open the Handler mappings configuration feature.

How do I host a Python API in IIS?

Insure you have CGI installed on your IIS: Go to Start -> Control Panel -> Programs and Features -> on the left hand side, go to "Turn Windows Features on or off" -> Under the IIS node, make sure CGI is installed: Download Python for Windows, from python.org (doesn't matter 2.7 or python 3, depends on your preference).


1 Answers

I've just followed that guide with following corrections:

  1. You should give permission on the site folder to App Pool's identity. I just went to App Pool's Advanced Settings > Process model > Identity and set it to local admin account for testing purposes.
  2. Correct environment variable name in step 4.13 is DJANGO_SETTINGS_MODULE, underscores were eaten by markup

and everything worked fine! If it's not applicable in your case please provide some additional details.

like image 65
cyberj0g Avatar answered Oct 08 '22 01:10

cyberj0g