'AssertionError while working on django rest framework
I have this error, i don't know how to fix it
AssertionError: Expected view ListingView to be called with a URL keyword argument named "pk". Fix your URL conf, or set the .lookup_field attribute on the view correctly
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())
]
Solution 1:[1]
We did this using podDisruptionBudgets and podAntiAffinity. We didn't bother setting any pre/post hooks.
Our ES cluster was not customer-facing so we could accept it going yellow sometimes and in fact, we expected it because we had Terabytes of data there and each time an ES node dropped off, the cluster would go yellow as the shard replicas could not be allocated.
By ensuring the PDBs are configured, you allow the k8s cluster to try to keep as many relevant pod replicas up as needed to match the requirement.
By using the antiaffinity, you make sure the pods don't end up landing on the same node, ensuring that if one k8s node goes down for upgrade, it only takes out one ES node, which can then come up elsewhere due to the PDBs.
Upon rejoining, the new ES node has to resync its shards so the cluster was still yellow during the transfer, after that it was green.
Out setup might not be perfect for what you're trying to do, but it worked for us.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Blender Fox |
