Python 通过视图django中的url传递paarmeter时,未找到页面错误

Python 通过视图django中的url传递paarmeter时,未找到页面错误,python,django,django-views,Python,Django,Django Views,我是python django的新手。在django中通过URL向视图传递参数时,我遇到了一个问题。 代码: views.py from django.shortcuts import render from django.http import HttpResponse def hello(request): text = "HEllo" return HttpResponse(text) def viewArticle(request, articleId): text

我是python django的新手。在django中通过URL向视图传递参数时,我遇到了一个问题。 代码: views.py

from django.shortcuts import render
from django.http import HttpResponse

def hello(request):
   text = "HEllo"
   return HttpResponse(text)

def viewArticle(request, articleId):
   text = "HEllo : %d"%articleId
   return HttpResponse(text)


urls.py

from django.conf.urls import url
from django.urls import path,include
from myapp import views

urlpatterns = [
path('hello/',views.hello,name='hello'),
path('article/(\d

+)/',views.viewArticle,name='article'),

]

图像:

您需要更改url,如下所示:

path('article/<int:articleId>/',views.viewArticle,name='article'),
path('article/',views.viewArticle,name='article'),
希望这项工作

这是您正在使用的。路径使用不带正则表达式的路由

您需要将url更改为

path('article/<int:articleId>/',views.viewArticle,name='article'),
path('article/',views.viewArticle,name='article'),

你的url应该是文章,而不是文章