500 internet server error error_log:TemplateSyntaxError: Caught ImportError while rendering: No module named friends
Recently I am using django and mod_wsgi on Apache.
I am follow the following steps found in a webpage:
"My application in / mnt / www /, the name of the called mysite, apache and created in the mysite media directory, and then do the following:"
create apache_django_wsgi.conf file, as follows:
Alias / site_media / / mnt / www / mysite / media /
<Directory /mnt/www/mysite/media>
Order allow, deny
Options Indexes
Allow from all
IndexOptions FancyIndexing
</ Directory>
Alias / media / / usr/local/lib/python2.5/site-packages/django/contrib/admin/media /
<Directory /usr/local/lib/python2.5/site-packages/django/contrib/admin/media>
Order allow, deny
Options Indexes
Allow from all
IndexOptions FancyIndexing
</ Directory>
WSGIScriptAlias / / mnt / www / mysite / apache / django.wsgi
<Directory /mnt/www/mysite>
Order deny, allow
Allow from all
</ Directory>
<Directory /mnt/www/mysite/apache>
Allow from all
</ Directory>
create django.wsgi file, as follows:
import os, sys
# Calculate the path based on the location of the WSGI script.
apache_configuration = os.path.dirname (__file__)
project = os.path.dirname (apache_configuration)
workspace = os.path.dirname (project)
sys开发者_如何学Go.path.append (workspace)
os.environ ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
os.environ ['PYTHON_EGG_CACHE'] = '/ tmp'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler ()
print>> sys.stderr, sys.path
I have followed these step but when I run it under Apache through a browser, I get a 500 Internet Server Error. Then I check the erro_log: it says:"TemplateSyntaxError: Caught ImportError while rendering: No module named friends" (friends is the name of one of my module)
The path of my site is /var/BigPrject/mysite
Everything looks good to me, except the project folder is not in the python path.
You can validate it by going to the console and trying to import friends
.
I am guessing, you can fix this, in you case, by adding the following line to your wsgi
file:
sys.path.append (project)
精彩评论