如何修复:http:// localhost:8000 / articles / update / 1

时间:2019-06-03 18:53:26

标签: django url

我遇到网址问题

当我单击“更新”按钮时,它会向我发送该网址:

http://localhost:8000/article/update/1

但是,我必须输入该网址:

http://localhost:8000/articles/update/1

我该如何解决这个问题?

urls.py //博客

from django.contrib import admin
from django.urls import path,include
from article import views

    urlpatterns = [
        path('admin/', admin.site.urls),
        path('', views.index, name="index"),
        path('about/', views.about, name="about"),
        path('articles/',include("article.urls")),
        path('user/',include("user.urls")),
      ]

urls.py //文章

from django.contrib import admin
from django.urls import path
from . import views

app_name = "article"

urlpatterns = [
    path('dashboard/',views.dashboard,name="dashboard"),
    path('addarticle/',views.addarticle,name="addarticle"),
    path('article/<int:id>',views.detail,name="detail"),

    path('update/<int:id>',views.updateArticle,name="update"),
]

1 个答案:

答案 0 :(得分:0)

确保在更新按钮后面您正在调用正确的URL 例如:

/ articles / update / {{article.id}}