0

I have a django website deployed on an IIS Server. in it, I have 2 different network paths I need to access via static

STATIC_URL = '/static/'

STATICFILES_DIRS = [
    "//server1/Shared1/folder/", "//Server2/folder2/",
]

Now, currently my IIS has a static virtual directory that is set to "server1" this allows me to work with all the files I have in that shared network drive and opertate properly.

enter image description here

The issue comes when I try to work with any files in the "server2" I don't know how to add it. I understand that exists something called "static root" but for that I need to do a "collect static" in this case, I can't do a collect static since both servers have over 60gb of data that I need to access.

Is there a way I'm not seeing for adding this second server to be able to be used via IIS?

enter image description here

Baldie47
  • 1,148
  • 5
  • 16
  • 45
  • Is this [post](https://stackoverflow.com/questions/32312590/how-to-fetch-static-css-files-with-django-on-iis) helpful to your problem ? – Hury Shen Jul 20 '21 at 06:05
  • Hello Hury, no, it doesn't help, I have the setup explained here. I am able to serve static content, my issue is trying to serve static content from 2 different places without runnig hte collectstatic (since the folder is big) I'm able to serve with a virtual directory static to 1 path but I don't know how to serve my 2nd path – Baldie47 Jul 20 '21 at 07:22
  • Do you mean add two paths as "Physical path" for static virtual directory ? – Hury Shen Jul 20 '21 at 07:35
  • yes, right now, as the screenshot, my virtual directory points to 1 path (network drive) however I have content I also need to serve from a 2nd network drive, and I don't have where to point this one since the "static" alias is already used. does this makes sense? – Baldie47 Jul 20 '21 at 07:54
  • from the screenshot, my static alias in IIS points to "//server1/Shared1/folder/" but I need to also access to the static files in "//Server2/folder2/" where and how do I set this in iis? – Baldie47 Jul 20 '21 at 07:56
  • In my opinion, we can't specify two physical paths for virtual path. But as a workaround, maybe you can have a try with create a new shared folder which contains the two folder (`//server1/Shared1/folder/` and `//Server2/folder2/`). Then use the new created shared folder as physical path. – Hury Shen Jul 20 '21 at 08:05
  • to create them with shortcuts would work? because they're in different network drives, I can't just move them to the same location and then point to that one. I'll try creating a folder in my webserver, that has shortcuts to the network drives of the 2 locations, and then point to that folder, is this what you mean? – Baldie47 Jul 20 '21 at 08:10
  • I'm not sure if this workaround can work, just suggest you have a try. – Hury Shen Jul 20 '21 at 08:21
  • yes, I understand, but I understood correctly your suggestion? thank you! – Baldie47 Jul 20 '21 at 08:22
  • Yes, I think your description is what I mean. – Hury Shen Jul 20 '21 at 08:31
  • uhm, sadly doesn't work, when I get a full path including the shortcut, it breaks the link since the shortcut changes the absolute path to the network one :( – Baldie47 Jul 20 '21 at 08:47

1 Answers1

0

For anyone that has the same type of issue. I was able to do this by adding a second virtual directory as subfolder for the first one

-The first one pointing to shared drive X -The second one as subfolder pointing to shared drive Y with an alias

and then I added a call for this second folder where needed such as "static/2ndserver"

with this was able to get the files from both separate network locations without having to do a "collectstatic" and bring them to a third place.

enter image description here

and in the template I call it by this:

<td><a href=' {% static  "/subfolder/" %}{{ datarow.path }}'>Open Document</a></td>
Baldie47
  • 1,148
  • 5
  • 16
  • 45