在 django rest 框架上工作时出现 AssertionError

AssertionError while working on django rest framework

我有这个错误,我不知道如何解决

AssertionError:预期使用名为“pk”的 URL 关键字参数调用视图 ListingView。修复您的 URL conf,或正确设置视图的 .lookup_field 属性

class ListingView(RetrieveAPIView):
    queryset = Listing.objects.order_by('-list_date').filter(is_published=True)
    serializer_class = ListingDetailSerializer
    look_field = 'slug'

urlpatterns = [
    path('', ListingsView.as_view()),
    path('search/', SearchView.as_view()),
    path('<slug>/', ListingView.as_view())
]

我觉得look_field应该改成lookup_field.

class ListingView(RetrieveAPIView):
    queryset = Listing.objects.order_by('-list_date').filter(is_published=True)
    serializer_class = ListingDetailSerializer
    lookup_field = 'slug'