简体   繁体   English

Django URL 出现 404 错误,即使它包含在 url 模式中

[英]404 Error with Django URL even though it is included in url patterns

Here's the error I'm getting:这是我得到的错误:

Page not found (404)
Request Method: GET
Request URL:    http://localhost:8000/bet/4/update
Using the URLconf defined in chessbet.urls, Django tried these URL patterns, in this order:
admin/[name='bet-home']
bet/<int:pk> [name='bet-detail']
bet/<int:pk>/update/> [name='bet-update']
about/ [name='bet-about']
bet/new/ [name='bet-create']
register/ [name='register']
login/ [name='login']
logout/ [name='logout']
yourprofile/ [name='yourprofile']

^media/(?P<path>.*)$

The current path, bet/4/update, didn't match any of these.

Now from what I see the current path is equivalent to the path I laid out for bet-update.现在从我看到的当前路径相当于我为下注更新布置的路径。 What am I doing wrong here?我在这里做错了什么?

Here is my urls.py:这是我的 urls.py:

urlpatterns = [
    path('', BetListView.as_view(), name = "bet-home"),
    path("bet/<int:pk>", BetDetailView.as_view(), name="bet-detail"),
    path("bet/<int:pk>/update/>", BetUpdateView.as_view(), name="bet-update"),
    path('about/', views.about, name = "bet-about"),
    path("bet/new/", BetCreateView.as_view(), name="bet-create") 
]

Bet detail which does something very similar works fine but bet update does not.做一些非常相似的事情的投注细节可以正常工作,但投注更新却不行。

Any help would be much appreciated.任何帮助将非常感激。

It seems that you have odd /> in update path should be看来您在更新路径中有奇怪的 /> 应该是

    path("bet/<int:pk>/update", BetUpdateView.as_view(), name="bet-update"),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM