1👍
✅
You should filter on the genre
field of the Genre
, so:
def g(request, G):
animes = anime.objects.filter(Genre__genre=G)
x = {'animes': animes}
return render(request, 'Anime/genre.html', x)
Note: Models in Django are written in PascalCase, not snake_case,
so you might want to rename the model fromtoanime
Anime
.
Source:stackexchange.com