0

I have a project with two apps, one is the website called 'web' and the other is called 'tools' which are a collection of tools for the admin/users.

What I want to do is to scan a folder of images in the web app from a method in the tools app. The images are in the static folder of web:

/web/static/web/images/

How can I get to this folder from the tools folder?

Here is what I have tried:

files = []
fileRoots = []
#path = STATIC_ROOT + 'web/images/'
for root, directories, filenames in os.walk(STATIC_IMAGES):#probably something wrong with the location
    for filename in filenames:
        files.append(os.path.join(root,filename))            
        fileRoots.append(root)

Also in the projects folder I have:

STATIC_IMAGES = '/web/static/web/images/'

How can I access these images?

Kevin
  • 3,077
  • 6
  • 31
  • 77

1 Answers1

0

I found this useful:

Get absolute path of django app

Here is what I did:

import tools, web

pth = web.__path__[0] + "/static/web/images"#os.path.join(tools.__path__,"static/web/images")
for root, directories, filenames in os.walk(pth):#probably something wrong with the location
    for filename in filenames:
        files.append(os.path.join(root,filename))            
        fileRoots.append(root)
Community
  • 1
  • 1
Kevin
  • 3,077
  • 6
  • 31
  • 77