Ich habe eine kleine Django-Website, die ich auf einem Apache 2.2 HTTP-Server ausführen möchte. Die Anwendung läuft gut mit "Python manage.py runserver".Fehler beim Deployment von Django auf Apache
Django Version: 1.0.2 final
Python: 2.5
OS: Windows 2000
ich durch die Schritte wen't im documentation und nach einiger Fummelei beschrieben, kam in der folgenden aus meiner httpd.conf.
<Location "/therap/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE settings
PythonOption django.root /therap
PythonDebug On
PythonPath "['D:/therap/therap'] + sys.path"
</Location>
MaxRequestsPerChild 1
D: \ therap \ therap den Ort beeing, wo mein manage.py ist.
Wenn ich versuche, in meinem Browser zu öffnen, sehe ich einen Fehler im Stil von Django verwendet
ImportError at/
No module named therap.urls
Request Method: GET
Request URL: http://****:8080/
Exception Type: ImportError
Exception Value:
No module named therap.urls
Exception Location: C:\python25\lib\site-packages\django\core\urlresolvers.py in _get_urlconf_module, line 200
Python Executable: C:\Programme\Apache Software Foundation\Apache2.2\bin\httpd.exe
Python Version: 2.5.1
Python Path: ['D:/therap/therap', 'C:\\WINNT\\system32\\python25.zip', 'C:\\Python25\\Lib', 'C:\\Python25\\DLLs', 'C:\\Python25\\Lib\\lib-tk', 'C:\\Programme\\Apache Software Foundation\\Apache2.2', 'C:\\Programme\\Apache Software Foundation\\Apache2.2\\bin', 'C:\\Python25', 'C:\\Python25\\lib\\site-packages', 'C:\\Python25\\lib\\site-packages\\pyserial-2.2', 'C:\\Python25\\lib\\site-packages\\win32', 'C:\\Python25\\lib\\site-packages\\win32\\lib', 'C:\\Python25\\lib\\site-packages\\Pythonwin', 'C:\\Python25\\lib\\site-packages\\wx-2.8-msw-unicode']
Server time: Mo, 23 Mär 2009 16:27:03 +0100
Es gibt eine urls.py in D ist (wie auf weißen Hintergrund schwarz Kurier gegenüber.): \ therap \ therap. Allerdings gibt es keine in D: \ therap \ therap \ main, wo die meisten meiner Code ist.
Ich habe dann versucht, die Ordner Eltern mit
<Location "/therap/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE therap.settings
PythonOption django.root /therap
PythonDebug On
PythonPath "['D:/therap'] + sys.path"
</Location>
MaxRequestsPerChild 1
Was mir einen anderen Fehler gab:
MOD_PYTHON ERROR
ProcessId: 2424
Interpreter: '***'
ServerName: '****'
DocumentRoot: 'C:/Programme/Apache Software Foundation/Apache2.2/htdocs'
URI: '/therap/'
Location: '/therap/'
Directory: None
Filename: 'C:/Programme/Apache Software Foundation/Apache2.2/htdocs/therap'
PathInfo: '/'
Phase: 'PythonHandler'
Handler: 'django.core.handlers.modpython'
Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\mod_python\importer.py", line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File "C:\Python25\Lib\site-packages\mod_python\importer.py", line 1229, in _process_target
result = _execute_target(config, req, object, arg)
File "C:\Python25\Lib\site-packages\mod_python\importer.py", line 1128, in _execute_target
result = object(arg)
File "C:\Python25\lib\site-packages\django\core\handlers\modpython.py", line 228, in handler
return ModPythonHandler()(req)
File "C:\Python25\lib\site-packages\django\core\handlers\modpython.py", line 201, in __call__
response = self.get_response(request)
File "C:\python25\Lib\site-packages\django\core\handlers\base.py", line 67, in get_response
response = middleware_method(request)
File "C:\python25\Lib\site-packages\django\middleware\locale.py", line 17, in process_request
translation.activate(language)
File "C:\python25\Lib\site-packages\django\utils\translation\__init__.py", line 73, in activate
return real_activate(language)
File "C:\python25\Lib\site-packages\django\utils\translation\trans_real.py", line 209, in activate
_active[currentThread()] = translation(language)
File "C:\python25\Lib\site-packages\django\utils\translation\trans_real.py", line 198, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "C:\python25\Lib\site-packages\django\utils\translation\trans_real.py", line 183, in _fetch
app = __import__(appname, {}, {}, [])
ImportError: No module named main
ich tue, um die Internationalisierung Modul, aber ich sehe nicht, warum es ein Problem verursacht bei dieser Punkt.
"main" ist der Name der einzigen Django-App (mit Ansichten, Modellen, Formen und so). Der vollständige Pfad ist D: \ therap \ therap \ main.
Ich habe __init__.py
-Dateien überall aus dem Hauptordner zu d: \ therap.
Jetzt weiß ich nicht, was ich noch tun könnte. Irgendwelche Ideen?
Vielen Dank. Es scheint so zu sein, wie du es beschrieben hast. Allerdings läuft meine Anwendung immer noch nicht.Es sagt, dass es keinen meiner Tische finden kann (wahrscheinlich alle mit sqlite3). Ich kann eine Nachfolgefrage stellen, wenn ich es nicht selbst herausfinden kann. – KarlsFriend