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<http://stackoverflow.com/questions/20322952/how-to-retrieve-static-files-contents-in-django-view>.
 
 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.
 

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/213e2cfa-63e3-48df-af54-858008f37648%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to