django向视图发送参数,url中传递参数

查看django版本:

python -m django --version

django3.0版本及以上使用:

from django.urls import re_path

urlpatterns = [
    re_path('^article/(\d+)', demo.views.viewArticle, name='article')
]

django3.0版本以下使用:

from django.conf.urls import patterns, include, url

urlpatterns = patterns(
   url(r'^article/(\d+)/', 'viewArticle', name = 'article'),
)

你可能感兴趣的:(django)