【发布时间】:2022-01-07 13:14:08
【问题描述】:
项目中的一切都在工作,但我只有这个请求有问题,我不知道它是什么。
heroku 日志:
2021-11-30T19:23:21.705472+00:00 app[web.1]: 10.1.43.186 - - [30/Nov/2021:19:23:21 +0000] "GET /api/player=1/matches HTTP/1.1" 500 145 "-" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36"
2021-11-30T19:23:21.707787+00:00 heroku[router]: at=info method=GET path="/api/player=1/matches" host=football-players-stats-api.herokuapp.com request_id=e94d6c13-3fbd-4825-b696-282992be5bc9 fwd="186.58.74.102" dyno=web.1 connect=0ms service=27ms status=500 bytes=403 protocol=https
观看次数:
class MatchesView(generics.ListAPIView):
serializer_class = MatchesSerializer
permissions = (IsAuthenticated)
def get_queryset(self):
player = self.kwargs['player']
return Matches.objects.filter(player=player).all()
网址:
app_name = 'api'
urlpatterns = [
path('',include(router.urls)),
path('player=<str:player>/matches',views.MatchesView)
]
【问题讨论】:
-
是否需要加
as_view()。所以views.MatchesView.as_view()
标签: python django heroku django-rest-framework