Django urls.py 未找到

发布于 2024-12-10 14:23:33 字数 1086 浏览 0 评论 0原文

为名为 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') 中定义)

urls.py 404 页面

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')

urls.py 404 page

, 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')

urls.py 404 page

, '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')

urls.py 404 page

, 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')

urls.py 404 page

, 'social'), (r'^(?P<User_id>\d+)/news

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')

urls.py 404 page

, 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')

urls.py 404 page

, 'news'), (r'^(?P<User_id>\d+)/email

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')

urls.py 404 page

, 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')

urls.py 404 page

, 'email'), (r'^(?P<User_id>\d+)/photos

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')

urls.py 404 page

, 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')

urls.py 404 page

, 'photos'), )

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')

urls.py 404 page

, 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')

urls.py 404 page

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

痴骨ら 2024-12-17 14:23:33

您需要从此处删除 $

(r'^OmniCloud_App/

以便它是:

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

$ 表示字符串结尾。

, include('OmniCloud_App.urls')),

以便它是:

$ 表示字符串结尾。

You need to remove the $ from here

(r'^OmniCloud_App/

so that it's:

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

The $ means end of string.

, include('OmniCloud_App.urls')),

so that it's:

The $ means end of string.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文