我有这个路由:
url(r'^article/(?P<article_id>\d+)/', views.ArticleList.as_view())
导致此功能:
class RSSList(APIView):
def get(self, request, *args, **kwargs):
article_id = kwargs.get('article_id')
但是当我尝试查询类似/ article / 34
的内容时我收到此错误:
TypeError: get() got an unexpected keyword argument 'article_id'
如何将article_id传递给get()?
谢谢
答案 0 :(得分:0)
你也可以这样
def get(self, request, article_id):
print(article_id) #for >3.2
print article_id # for 2.7
如果使其成为选择,那么就像这样更新
def get(self, request, article_id=None):