Django is a popular Python web framework, below is how to use IIS(Internet Information Service) to host Django application on Windows.

  • Install Python on Windows https://python.org
  • Create a python virtual environment so your future development won’t rely on existing Python executables on your Windows.(This is not really necessary as most Windows on PC is not a multi-user operating system anyway but keep this as a best practice)
cd c:\work\python\qlik_venv
python –m venv venv
  • Activate the venv
cd venv
.\scripts\activate
  • Install Django
pip install django
  • Create a project
django-admin  startproject qlikua
  • Create an app at the top level
python manage.py startapp qlikua_app

Once the above is done, you should have file structure similar to below

 

 

 

 

 

 

Test everything is working so far by using Django’s own web server(python manage.py runserver), you can follow this Django article for great details.

Now it’s now for IIS

  • Install wfastcgi, which is provided/supported by Microsoft(this is an article on this module). Remember to keep your venv activated.
pip install wfastcgi
  • Configure fast cgi at IIS level
    1. Create a FastCGI entry

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2. Create a site

 

 

 

 

 

 

 

 

 

 

 

3. Add the following in “Application Settings”. Note WSGI_HANDLER is a variable “application” created by file qlikua\wsgi.py

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4. Add an entry in “Hander Mappings” (Add Module Mapping…), after this a web.config will be created under qlik_venv\qlikua

 

 

 

 

 

 

 

 

 

 

 

 

5. Review web.config which was created by the above, you can modify those variables manually

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • Start the site and view the app in a browser

p.s  A very detailed step-by-step post for running Django on IIS

http://blog.mattwoodward.com/2016/07/running-django-application-on-windows.html

Running a Django application on IIS
Tagged on:             

Leave a Reply

Your email address will not be published. Required fields are marked *

− 3 = 2

This site uses Akismet to reduce spam. Learn how your comment data is processed.