1đź‘Ť
âś…
category_id
appears to be a string slug (e.g. “category1_test”) that is extracted from the url, but you are trying to use it as a foreign key (int
). You could do this:
lst = Info.objects.filter(category__slug=category_id).order_by("-created")
or, rearranging:
category = get_object_or_404(Category, slug=category_id)
lst = Info.objects.filter(category=category).order_by("-created")
(Note: I would not assign to the name “list” if I were you. You’re hiding the builtin list
!)
Source:stackexchange.com