How to get the detailed page by slug and not id in Django Rest Framework class based views

I am building an API using Django Rest Framework. I have the /api/localities endpoint where all of the objects on my database are displayed. Now I want to create the endpoint for a single page of a particular locality, and I want to make it by slug and not id for example /api/localities/munich. I am… Read More How to get the detailed page by slug and not id in Django Rest Framework class based views

How change a function based view into a class based?

I want to write a category detail view in order to do so i want to change this function based view def CategoryView(request, cats): category_posts = Post.objects.filter(category=cats.replace(‘-‘, ‘ ‘)) return render(request, ‘categories.html’, {‘cats’:cats.replace(‘-‘, ‘ ‘).title(), ‘category_posts’:category_posts}) into the class based view. My first question: 1. How to do so?; 2.How also change the url for… Read More How change a function based view into a class based?