[Answered ]-Reverse for 'post_detail' with arguments '('chempion',)' not found. 1 pattern(s) tried: ['(?P<category_slug>

1👍

The post_detail view requires two slugs: one of slug for the category, and one for the post.

If your Post model for example has a ForeignKey to the Category model, you can reference this with:

<a href="{% url 'post_detail' next_post.category.slug next_post.slug %}">Next</a>

In your view, you might want to check both the slug for the category and for the post, so:

def post_detail(request, category_slug, slug):
    post = get_object_or_404(Post, category__slug=category_slug, slug=slug)
    # …

Leave a comment