1👍
✅
You need to define your url to have the category as a named parameter, so your view would take that extra parameter and query for the course:
url:
url(r'^categories/(?P<course_name>\w+)/$', views.categories_pages)
views.py
def categories_pages(request, course_name):
if request.user.is_authenticated():
courses = Course.objects.filter(
published_date__lte=timezone.now(),
categories__name__icontains=course_name
).order_by('published_date')
context = {
"courses": courses
}
return render(request, 'categories/categories-page.html', context)
Source:stackexchange.com