Django urls.py 未找到
为名为 OmniCloud_App
的 Django 应用设置 URL。访问 /OmniCloud_App/signup 时出现错误,提示找不到 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/ 即可正确呈现“主页”页面(也在 include('OmniCloud_App.urls') 中定义)
Setting up the urls for a Django app called OmniCloud_App
. Getting and error when accessing /OmniCloud_App/signup that the url is not found. here is the main urls.py:
urlpatterns = patterns('',
(r'^OmniCloud_App/
which then includes OmniCloud_App/urls.py:
urlpatterns = patterns('OmniCloud_App.views',
(r'^', 'home'),
(r'^signup/', 'signup'),
(r'^(?P<User_id>\d+)/
so signup should go to the signup method in views.py:
def signup(request):
return render_to_response('OmniCloud_App/Templates/OmniCloud/signup.html', context_instance=RequestContext(request))
Any reason why this won't work? Here is the 404, which implies that it never got past the initial urls.py file, although visiting simply /OmniCloud_App/ renders the 'home' page correctly (which is also defined in the include('OmniCloud_App.urls')
, include('OmniCloud_App.urls')),
(r'^admin/', include(admin.site.urls)),
)
which then includes OmniCloud_App/urls.py:
so signup should go to the signup method in views.py:
Any reason why this won't work? Here is the 404, which implies that it never got past the initial urls.py file, although visiting simply /OmniCloud_App/ renders the 'home' page correctly (which is also defined in the include('OmniCloud_App.urls')
, 'profile'),
(r'^(?P<User_id>\d+)/social
so signup should go to the signup method in views.py:
Any reason why this won't work? Here is the 404, which implies that it never got past the initial urls.py file, although visiting simply /OmniCloud_App/ renders the 'home' page correctly (which is also defined in the include('OmniCloud_App.urls')
, include('OmniCloud_App.urls')),
(r'^admin/', include(admin.site.urls)),
)
which then includes OmniCloud_App/urls.py:
so signup should go to the signup method in views.py:
Any reason why this won't work? Here is the 404, which implies that it never got past the initial urls.py file, although visiting simply /OmniCloud_App/ renders the 'home' page correctly (which is also defined in the include('OmniCloud_App.urls')
so signup should go to the signup method in views.py:
Any reason why this won't work? Here is the 404, which implies that it never got past the initial urls.py file, although visiting simply /OmniCloud_App/ renders the 'home' page correctly (which is also defined in the include('OmniCloud_App.urls')
which then includes OmniCloud_App/urls.py:
so signup should go to the signup method in views.py:
Any reason why this won't work? Here is the 404, which implies that it never got past the initial urls.py file, although visiting simply /OmniCloud_App/ renders the 'home' page correctly (which is also defined in the include('OmniCloud_App.urls')
so signup should go to the signup method in views.py:
Any reason why this won't work? Here is the 404, which implies that it never got past the initial urls.py file, although visiting simply /OmniCloud_App/ renders the 'home' page correctly (which is also defined in the include('OmniCloud_App.urls')
which then includes OmniCloud_App/urls.py:
so signup should go to the signup method in views.py:
Any reason why this won't work? Here is the 404, which implies that it never got past the initial urls.py file, although visiting simply /OmniCloud_App/ renders the 'home' page correctly (which is also defined in the include('OmniCloud_App.urls')
so signup should go to the signup method in views.py:
Any reason why this won't work? Here is the 404, which implies that it never got past the initial urls.py file, although visiting simply /OmniCloud_App/ renders the 'home' page correctly (which is also defined in the include('OmniCloud_App.urls')
which then includes OmniCloud_App/urls.py:
so signup should go to the signup method in views.py:
Any reason why this won't work? Here is the 404, which implies that it never got past the initial urls.py file, although visiting simply /OmniCloud_App/ renders the 'home' page correctly (which is also defined in the include('OmniCloud_App.urls')
so signup should go to the signup method in views.py:
Any reason why this won't work? Here is the 404, which implies that it never got past the initial urls.py file, although visiting simply /OmniCloud_App/ renders the 'home' page correctly (which is also defined in the include('OmniCloud_App.urls')
which then includes OmniCloud_App/urls.py:
so signup should go to the signup method in views.py:
Any reason why this won't work? Here is the 404, which implies that it never got past the initial urls.py file, although visiting simply /OmniCloud_App/ renders the 'home' page correctly (which is also defined in the include('OmniCloud_App.urls')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要从此处删除
$
,以便它是:
$ 表示字符串结尾。
You need to remove the
$
from hereso that it's:
The $ means end of string.