设置名为OmniCloud_App
的Django应用的网址。访问/ OmniCloud_App /注册时未获取URL的获取和错误。这是主要的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 /正确呈现'home'页面(也在include('OmniCloud_App.urls')
答案 0 :(得分:7)
您需要从此处删除$
(r'^OmniCloud_App/$', include('OmniCloud_App.urls')),
所以它是:
(r'^OmniCloud_App/', include('OmniCloud_App.urls')),
$表示字符串的结尾。