500 internet server error error_log: TemplateSyntaxError: Caught ImportError during rendering: no module named friends

I recently use django and mod_wsgi on Apache.

I follow the following steps on a webpage:

"My application is in / mnt / www /, the name of the called mysite, apache and created in the mysite media directory, and then do the following:"

create the 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 the 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.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 followed this step, but when I run it under Apache through a browser, I get 500 Internet Server Error. Then I check erro_log: it says: "TemplateSyntaxError: Caught ImportError when rendering: there is no module named friends" (friends is the name of one of my modules)

My site path is / var / BigPrject / mysite

+4
source share
1 answer

Everything looks good to me, except the project folder is not in the python path.

You can verify it by going to the console and selecting import friends .

I assume you can fix this in your case by adding the following line to your wsgi file:

 sys.path.append (project) 
+6
source

All Articles