2012-05-18 31 views
0

我想在我的项目(称为注册)settings.py中设置ROOT_URLCONF各种字符串:ROOT_URLCONF = 'registration.urls'ROOT_URLCONF = 'foo.urls'ROOT_URLCONF = 'monkey.urls'ROOT_URLCONF = 'registration.registration.urls'为什么Django会忽略我的ROOT_URLCONF设置?

无论如何,我得到我的主页这样的输出:

Page not found (404) 
Request Method: GET 
Request URL: http://78.198.124.245/ 
Directory indexes are not allowed here. 
You're seeing this error because you have DEBUG = True in your Django settings file. 

这是为什么?这里是我用来配置Passenger(passenger_wsgi.py)的文件。该文件位于“/ home/david/registration/registration /”中。

import os, sys 

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "registration.settings") 

# This application object is used by any WSGI server configured to use this 
# file. This includes Django's development server, if the WSGI_APPLICATION 
# setting points here. 
from django.core.wsgi import get_wsgi_application 
application = get_wsgi_application() 

sys.path.append(os.getcwd()) 
sys.path.append("/home/david/registration/registration") 
sys.path.append("/home/david/registration/registration/app") 

/home/david/registration/registration/urls.py看起来像这样。

from django.conf.urls import patterns, include, url, http 

def myFunction(request): 
    return http.HttpResponse("A mapped URL") 

urlpatterns = patterns('', 
    (r'^$', 'myFunction') 
) 

为什么我的Django应用程序完全无视我的ROOT_URLCONF设置,我每次访问我的主页时返回相同的输出?

回答

0

您的任何尝试都不在python路径中。如果路径是/home/david/registration/registration,并且网址在/home/david/registration/registration/urls.py那么应该从第一到第二的相对路径是什么?

相关问题