-1

With django (python server) is possible to add more that one path to serve static files using STATICFILES_DIRS = ("C:/some/path/static_two",) on settings file, and works fine, but on production server, in my case IIS, is that possible?

I tried adding two virtual dirctories each one whit different paths/locations, but doesn't works, the static file from the second directiry "C:/some/path/static_two" doesn't shows.

Someone can help me on how configurate IIS two serve static files from more that one location.

thanks in advance.

M. Gar
  • 889
  • 4
  • 16
  • 33

1 Answers1

3

You are confused about what that setting does.

STATICFILES_DIRS is the place(s) where static files are copied from when you run manage.py collectstatic. The place they are copied to is STATIC_ROOT, which is a singular directory. You need to set up your web server to serve files from there, not from STATICFILES_DIRS.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
  • Hi Daniel, let me explain my situation. I have this conf in my setting `STATIC_ROOT = path.join(PROJECT_ROOT, 'static').replace('\\', '/')` this point to the path of my project like this `C:/user/docs/myproject/static/` that serves all the files in that location and its right, but then I need to show images from `C:/something/images/` at first when I use the complete path from the second location doesn't show the images but when I add this `STATICFILES_DIRS = ("C:/something/images",)` and try it, the images were shown I try to do the same on IIS hope I explain my situation. – M. Gar Jan 18 '19 at 18:43
  • I'm not sure of the relevance of any of that. As I said, STATICFILES_DIRS is the source directory. You don't point IIS at that, you point it at whatever STATIC_ROOT is. – Daniel Roseman Jan 18 '19 at 19:56
  • Because on IIS to serve the files have to configure the virtual directory to the static folder so I try to add both directories but didn't work. – M. Gar Jan 18 '19 at 23:15
  • I don't know how to explain it any clearer. Put both those directories in STATICFILES_DIRS. Set STATIC_ROOT to a *different* directory. Point IIS at that directory. Run collectstatic. – Daniel Roseman Jan 18 '19 at 23:25