1👍
Most likely the issue is that you are using package-relative import statements with in your project, yet Apache has no knowledge of the proper python path. For instance, with this specific import error you are getting, I assume in your fparser.py
you are doing something like from profile import website_feed_address
. You might try explicitly including your project package in your django.wsgi:
sys.path.append('d:/code/projects-dev/project')
sys.path.append('d:/code/projects-dev/project/project')
An even better recommendation is that you set up a virtualenv for you project. The benefit of doing so will allow your project to contain its own site-packages environment, so that any dependencies you install will live with the project env. Then in Apache you can tell mod_wsgi where the python environment is:
# or wherever you decide to create the virtualenv
WSGIPythonHome d:/code/projects-dev/project/project
Setting the pythonpath via Apache
You can also try setting the PYTHONPATH for your wsgi app in the Apache conf:
WSGIPythonPath "d:/code/projects-dev/project/project"
*Note in that link where it makes the distinction between wsgi embedded mode and daemon mode.
Completely alternative approach to addressing the import issue
While my previous suggestions were addressing the PYTHONPATH and importing your profile
module, based on the fact that you are simply using it to pass in a constant, I would suggest you just make use of the settings.py, as thats what it is for (declaring constants):
settings.py
WEBSITE_FEED_ADDRESS = "http://foo.com"
fparser.py
from django.conf import settings
...
self.pFeed = feedparser.parse(settings.WEBSITE_FEED_ADDRESS)
You can be pretty sure that the django environment will always make the settings module available to you. The common approach is to have apps add to the settings, to provide default constants.
0👍
If you move profile.py into the project folder it will be inside a package. Then you can do:
from project.profile import website_feed_address
- [Answer]-Django block repeated requests
- [Answer]-Django: a custom view inside /static/ directory
- [Answer]-Using jinja2 macro from filter using jingo
- [Answer]-Why Django created stacked element for custom through model