3

I successfully deployed my Django site to IIS7 but I still have problems about how to configure IIS to serve the static files. I tried many many things from the internet but nothing seems to work. Everything is working fine on Django server (manage.py runserver) and with debug = True, but as soon as I turn off debug (debug = False) and open it on IIS, the bootstrap css and js are not loaded.

Do you have any ideas about why I'm experiencing this behavior? Perhaps you could point me to a step-by-step guide to help me?

Luc Touraille
  • 79,925
  • 15
  • 92
  • 137
Karim Tarek
  • 391
  • 1
  • 5
  • 19

3 Answers3

5

Right click on your website in IIS7 manager and

  1. add a virtual directory
  2. name it with the same name of your folder you want IIS to handle. lets say static
  3. add the path to your real static folder in your application mine was in myproject/static then ok

and here you go :)

Karim Tarek
  • 391
  • 1
  • 5
  • 19
1

If you are using django >= 1.3 and following the doc you are probably using the 'staticfiles' app.

  1. First, you must configure your II7 to serve static files from the chosen path, by default URL: /static/ and PATH /staticfiles/ (I have no experience with II7 but the conf should be straightforward)
  2. Then run ./manage.py collectstatic to move the static files into the correct path

and you should be done...

More info on production settings here.

Stefano
  • 18,083
  • 13
  • 64
  • 79
  • Unfortunately i don't use the staticfiles app :( .. but i found the solution .. i will post it as an answer now – Karim Tarek Jul 18 '12 at 10:33
  • @Anonymous then I strongly suggest to use staticfiles! In any case the same solution should apply, just the paths will change... – Stefano Jul 18 '12 at 10:45
0

You also need to insert a web.config file into the static directory for IIS to serve the files.

See: Django Static Files - 404

Community
  • 1
  • 1
Paul
  • 13
  • 4