I am having trouble configuring Apache and mod_python to work with my
project.
I am using Ubuntu Linux 7.10 with Apache 2. My project is in
/var/www/polls directory. This is also where the settings.py file is.
This directory and all files and directories are owned by www-data (the
user under which Apache is running) and they have 755 rights.
I have configured Apache httpd.conf file like so (only relevant parts
are included):
<Directory "/var/www/polls/">
Order allow,deny
allow from all
</Directory>
<Location "/polls/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonPath "['/var/www/polls'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE polls.settings
PythonDebug On
</Location>
I am getting the following error when I access ciaran.dmc.umn.edu/polls
. Any help is appreciated.
Thanks, Tonu
MOD_PYTHON ERROR
ProcessId: 13754
Interpreter: 'ciaran.dmc.umn.edu'
ServerName: 'ciaran.dmc.umn.edu'
DocumentRoot: '/var/www/'
URI: '/polls/'
Location: '/polls/'
Directory: None
Filename: '/var/www/polls/'
PathInfo: ''
Phase: 'PythonHandler'
Handler: 'django.core.handlers.modpython'
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1229, in _process_target
result = _execute_target(config, req, object, arg)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1128, in _execute_target
result = object(arg)
File "/usr/lib/python2.5/site-packages/django/core/handlers/modpython.py", line 222, in handler
return ModPythonHandler()(req)
File "/usr/lib/python2.5/site-packages/django/core/handlers/modpython.py", line 185, in __call__
self.load_middleware()
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py", line 31, in load_middleware
for middleware_path in settings.MIDDLEWARE_CLASSES:
File "/usr/lib/python2.5/site-packages/django/conf/__init__.py", line 28, in __getattr__
self._import_settings()
File "/usr/lib/python2.5/site-packages/django/conf/__init__.py", line 59, in _import_settings
self._target = Settings(settings_module)
File "/usr/lib/python2.5/site-packages/django/conf/__init__.py", line 94, in __init__
raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'polls.settings' (Is it on sys.path? Does it have syntax errors?): No module named polls.settings
Hello,
I am having trouble configuring Apache and mod_python to work with my
project.
I am using Ubuntu Linux 7.10 with Apache 2. My project is in
/var/www/polls directory. This is also where the settings.py file is.
This directory and all files and directories are owned by www-data (the
user under which Apache is running) and they have 755 rights.
I have configured Apache httpd.conf file like so (only relevant parts
are included):
<Directory "/var/www/polls/">
Order allow,deny
allow from all
</Directory>
<Location "/polls/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonPath "['/var/www/polls'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE polls.settings
PythonDebug On
</Location>
I am getting the following error when I access ciaran.dmc.umn.edu/polls
ImportError: Could not import settings 'polls.settings' (Is it on sys.path? Does it have syntax errors?): No module named polls.settings
<Location "/polls/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonPath "['/var/www'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE polls.settings
PythonDebug On
</Location>
I am now able to get past the previous error. However, I now get the
error about URLConf. I was able to run the project on the development
server with the current URL configuration. I am not quite sure what I
need to change in my URLConf file. Thanks for your help.
Tonu
Page not found (404)
Request Method: GET
Request URL: http://ciaran.dmc.umn.edu/polls/
Using the URLconf defined in |polls.urls|, Django tried these URL
patterns, in this order:
1. ^ ^$
2. ^ ^poll/(?P<slug>[^\.^/]+)/$
3. ^ ^create/$
4. ^ ^help/$
5. ^ ^results/(?P<slug>[^\.^/]+)/$
6. ^ ^admin/
7. ^ ^site_media/(?P<path>.*)$
8. ^admin/
The current URL, |polls/|, didn't match any of these.
The URLConf in polls/directory is following:
from django.conf.urls.defaults import *
urlpatterns = patterns('',
# Example:
(r'^', include('polls.pollngo.urls')),
# Uncomment this for admin:
(r'^admin/', include('django.contrib.admin.urls')),
)
The URLConfi in pollngo directory is following:
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
urlpatterns = patterns('pollngo.views',
(r'^$', 'index'),
(r'^poll/(?P<slug>[^\.^/]+)/$', 'question'),
(r'^create/$', 'create'),
(r'^help/$', 'help'),
(r'^results/(?P<slug>[^\.^/]+)/$', 'results'),
)
urlpatterns += patterns('',
(r'^admin/', include('django.contrib.admin.urls')),
)