2011-10-18 105 views
0

爲Django應用程序設置名爲OmniCloud_App的網址。訪問/ OmniCloud_App /註冊找不到url時出現錯誤。這裏是主urls.py:Django urls.py找不到

urlpatterns = patterns('', 
    (r'^OmniCloud_App/$', include('OmniCloud_App.urls')), 
    (r'^admin/', include(admin.site.urls)), 
) 

然後包括OmniCloud_App/urls.py:

urlpatterns = patterns('OmniCloud_App.views', 
    (r'^', 'home'), 
    (r'^signup/', 'signup'), 
    (r'^(?P<User_id>\d+)/$', 'profile'), 
    (r'^(?P<User_id>\d+)/social$', 'social'), 
    (r'^(?P<User_id>\d+)/news$', 'news'), 
    (r'^(?P<User_id>\d+)/email$', 'email'), 
    (r'^(?P<User_id>\d+)/photos$', 'photos'), 
) 

所以註冊應該去註冊方法views.py:

def signup(request): 
    return render_to_response('OmniCloud_App/Templates/OmniCloud/signup.html', context_instance=RequestContext(request)) 

任何原因,這將無法正常工作?這裏是404,這意味着它從來沒有得到過初始urls.py文件,雖然正確地參觀簡單/ OmniCloud_App /渲染「主頁」(這在include('OmniCloud_App.urls')

urls.py 404 page

回答

7

你也被定義需要從這裏

(r'^OmniCloud_App/$', include('OmniCloud_App.urls')), 

刪除$以便它:

(r'^OmniCloud_App/', include('OmniCloud_App.urls')), 

的$ M即將結束的字符串。

+0

啊挺好的。我曾嘗試過,但接受/ OmniCloud_App/*(任何字符串)我還需要添加$後註冊/ – Chris