The __file__ attribute of a module can be used as a starting point for
getting at data files within a python package. However, packages can
be installed in zipped format, so if you need to account for this you
can use the pkg_resources module in setuptools:
http://peak.telecommunity.com/DevCenter
Sorry, I was unclear. I don't mean that these files contain python
source code. They contain text that I want to read from certain
requests to my app. So the question is where to put the files (under
the app directory I assume), and how to refer to them using a
relative path, or how I can
Django makes python aware of your app folder when you install the app
so you can just do:
from appname.resources.filename import function
That should work whenever your app is propperly installed.
On 3 Mar., 21:41, Jack Orenstein wrote:
> I have a small number of files that need to be accessib
I have a small number of files that need to be accessible to my
Django application. These are part of the application, and so should
be treated as source code. The question is where to put them? Putting
them under MEDIA_ROOT doesn't seem right. They go with the
application so they should b
4 matches
Mail list logo