I'm having a problem with trying to find an image file so I can embed it in an openpyxl file. What I want to do is be able to locate this file, regardless of OS, and regardless of whether DEBUG is True or False.
The problem is that I've got development occurring on both Windows and Mac (and a Red Hat production server), and so my STATICFILES_DIRS setting has paths for both OSs, plus a different STATIC_ROOT for production. When I'm using the {% static %} type operations in templates, there doesn't seem to be any problem (i.e., all my javascript and css files work on all OSs and in development and production), but in actually trying to locate a file within a view, I'm getting a "The joined path (C:\Users\Shawn\Sites\sdcgis\images\DallasDColor.JPG) is located outside of the base path component (C:\Users\Shawn\Sites\sdcgis\static)". Obviously, that's because the first path in STATICFILES_DIRS is a Mac, UNIX style path, not a Windows path.
The pattern I'm using to try and accomplish this is found
here. My code is currently:
from django.contrib.staticfiles.finders import find
...
img_path = '/images/DallasDColor.JPG'
abs_path = find(img_path, True)
logo = Image(abs_path)
How to accomplish what I need to given this scenario? Thanks all.