Hello I am migrating my app to use class based views instead of function based views. In my old code I was able to get the absolute URL of an object related to a function view this way:
class Category(models.Model):
name = models.CharField(max_length=100,unique=True)
slug = models.SlugField(unique=True)
description = models.TextField()
parent = models.ForeignKey('self',null=True,blank=True)
def get_absolute_url(self):
return reverse('blog.views.showcategory',args=[str(self.slug)])
I couldn't find what I should change in my get absolute url function in order to get the same result.
This is my new class based view
class CategoryView(ListPosts):
template_name = "postlist.html"
context_object_name="posts"
def get_queryset(self):
return Post.objects.filter(category__slug=self.kwargs['slug']).order_by('created')
Thanks!