python django views request传参问题 20
使用的是python3,django2.0传递两个参数时defshowpost(request,slug):出现showpost()missing1requiredpos...
使用的是python3,django2.0
传递两个参数时def showpost(request,slug):
出现showpost() missing 1 required positional arguments: 'slug'错误,,
slug变量在models中定义的, 展开
传递两个参数时def showpost(request,slug):
出现showpost() missing 1 required positional arguments: 'slug'错误,,
slug变量在models中定义的, 展开
1个回答
展开全部
https://docs.djangoproject.com
views.py
1 2 | def article_detail(request, slug): pass |
urls.py
1 2 3 4 5 | urlspattern = [ ... path( 'articles/<slug:slug>/' , views.article_detail), # re_path(r'^articles/(?P<slug>[\w-]+)/$', views.article_detail), ] |
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询