Django on IIS

60 views
Skip to first unread message

Larry Martell

unread,
Dec 17, 2018, 6:19:51 PM12/17/18
to django...@googlegroups.com
Anyone have any experience setting up a Django app to work with IIS? I
have inherited what I was told is a working system, but it's not
working. Before I post details of my issues and questions I wanted to
see if anyone here has successfully got a Django app to run with IIS.

Alex Heyden

unread,
Dec 17, 2018, 10:17:08 PM12/17/18
to django...@googlegroups.com
I have recently, and it was equal parts misery and pain. FastCGI via wfastcgi, as outlined at http://blog.mattwoodward.com/2016/07/running-django-application-on-windows.html

I also had to downgrade from Python 3.7 to Python 3.6

I wouldn't really consider myself an expert on the subject. All I can say is that it is possible.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACwCsY7bk-c7Za-PGUbaEkftA8Xxqd%2BaCUPkaQryW-1kXX0_nQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Mike Dewhirst

unread,
Dec 17, 2018, 11:11:28 PM12/17/18
to django...@googlegroups.com
On 18/12/2018 2:16 PM, Alex Heyden wrote:
> I have recently, and it was equal parts misery and pain. FastCGI via
> wfastcgi, as outlined at
> http://blog.mattwoodward.com/2016/07/running-django-application-on-windows.html
>
> I also had to downgrade from Python 3.7 to Python 3.6
>
> I wouldn't really consider myself an expert on the subject. All I can
> say is that it is possible.

I once had to implement a web service on a Windows server and eventually
installed Apache. That worked brilliantly although it wasn't a heavy
duty application. Django works well on Windows so Apache is a fallback
if IIS doesn't cut it for you.


>
> On Mon, Dec 17, 2018 at 5:19 PM Larry Martell <larry....@gmail.com
> <mailto:larry....@gmail.com>> wrote:
>
> Anyone have any experience setting up a Django app to work with IIS? I
> have inherited what I was told is a working system, but it's not
> working. Before I post details of my issues and questions I wanted to
> see if anyone here has successfully got a Django app to run with IIS.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to django-users...@googlegroups.com
> <mailto:django-users%2Bunsu...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2Bv0ZYVWO5bFTx%3D6im_dLWwPWz1FoDcFVDN9GXREj%3Dp49f2FcA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CA%2Bv0ZYVWO5bFTx%3D6im_dLWwPWz1FoDcFVDN9GXREj%3Dp49f2FcA%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Avraham Serour

unread,
Dec 18, 2018, 4:23:13 AM12/18/18
to django-users
I feel your pain, once I had to deploy a django project on windows, after trying many different options I installed cygwin and form there nginx+uwsgi like any other normal person.

Today microsoft have WSL, I think you may use that too, you can still use IIS to route traffic and forward the http connections. Maybe not as efficient as it could be but I think it will save you headaches.

Good luck

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.

Roger Gammans

unread,
Dec 18, 2018, 4:36:04 AM12/18/18
to django...@googlegroups.com
Hi,

I was looking at this back in November., although I'm not a Powershell or Windows expert I start to put together a powershell script to automate the setup, although there was a couple of lose ends.

Most critically the order of handlers is import and you need to force the static files handler to be primary for media and static directories as whatever handler (by script uses fastcgi / wfastcgi.py) use use to interface with wsgi as primary at the root level. (Eg so media and static overrides the root with their local config)

Unfortunately I couldn't find anyway to control the handler ordering through powershell, I'm waiting on a window colleague to fix it up, but it is no longer a prioirty as the project as move away form windows hosting.

If there is interest I'll see what I can do about getting the script public.


-- 
Roger Gammans <rgam...@gammascience.co.uk>
Gamma Science

Larry Martell

unread,
Dec 18, 2018, 10:41:42 AM12/18/18
to django...@googlegroups.com
I am following the instructions I found here:

https://www.toptal.com/django/installing-django-on-iis-a-step-by-step-tutorial

I am up to this point: 'Configuring IIS to run a FastCGI application'
It says 'Click OK on the handler information dialog. IIS will then ask
you to confirm the creation of a matching FastCGI application entry
which you will need to confirm. This entry will be visible in the
FastCGI Settings feature, accessible at the root screen of the IIS
Management Console'

But after I set up the Module Mapping and do the above there is no
entry for the handler in the FastCGI Settings.

Anyone know what I may be doing wrong or how to proceed?

vishal sharma

unread,
Dec 18, 2018, 10:47:12 AM12/18/18
to django...@googlegroups.com
Can someone send me the code of upload multiple files from admin Django?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.

Roger Gammans

unread,
Dec 18, 2018, 10:50:15 AM12/18/18
to django...@googlegroups.com
Larry,


My script draws from the following urls all of which I found useful.



I think you might not have all the correct 'features' installed, specifically you are probably missing CGI.
The PS line to install that seems to be:-

	Enable-WindowsOptionalFeature -Online -FeatureName IIS-CGI

Hope this helps a little.

Larry Martell

unread,
Dec 18, 2018, 12:09:20 PM12/18/18
to django...@googlegroups.com
Thanks. I ran that command, and I checked the settings and CGi is
installed and enabled. I have the CGI icon in the IIS config page, but
I do not have the FAST-CGI which is what all the docs seem to refer
to.

On Tue, Dec 18, 2018 at 10:49 AM Roger Gammans

Larry Martell

unread,
Dec 18, 2018, 12:29:52 PM12/18/18
to django...@googlegroups.com
Get-WindowsFeature shows that web-cgi is installed but not iis-cgi.
Are these the same?

Roger Gammans

unread,
Dec 18, 2018, 12:34:04 PM12/18/18
to django...@googlegroups.com
On 18 December 2018 17:28:41 GMT, Larry Martell <larry....@gmail.com> wrote:
>Get-WindowsFeature shows that web-cgi is installed but not iis-cgi.
>Are these the same?
>
Maybe. I think they Microsoft renamed on to the other. My script was for the most recent iteration of windows server.


--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

Roger Gammans

unread,
Dec 18, 2018, 4:31:40 PM12/18/18
to django...@googlegroups.com
Larry,


Hmm, you may have reached the end of how I can help, but two things come to mind:-

1 It might be worth trying a reboot, to ensure IIS and dependent services are all reloaded.
2 I'm not sure the icon was created; I think I had to manually add the handler which created the icon. ( remember
having to select the name dome a combo select box. at one point)

My script goes straight on from the adding the features, to install python and then create a fastcgi handler with

	New-WebHandler -Name "DjangoFastCGI" -Path "*" -Verb "GET,POST" -Modules FastCgiModule `
                       -ResourceType Unspecified -ScriptProcessor "$PYEXE|-m wfastcgi"

(I've manually wrapped the above and added a '`' as the line continuation character ; and note the PYEXE variable
which would have been set to "C:\python36\python.exe" in my case. )

Which is the command line version of point 2 above.

IIS also a has a tendency to read a web.config XML in the IIS site root; from which I think a lot of this can be set from. You can certainly set environment variable there (such as PYTHONPATH , or DJANGO_SETTINGS_MODULE ).


HTH,
--
Roger

Larry Martell

unread,
Dec 19, 2018, 2:43:59 PM12/19/18
to django...@googlegroups.com
Thanks very much Roger. I ran your command (updated for my system),
and then it started working.

On Tue, Dec 18, 2018 at 4:31 PM Roger Gammans
Reply all
Reply to author
Forward
0 new messages