2👍
✅
The problem is in your views.py file.
In this code:
def tag_detail(request, tag):
tag = get_object_or_404(Tag, tag=tag.name)
return render(request, 'blog/tags_detail.html', {'tag': tag})
Here you wrote :
tag = get_object_or_404(Tag, tag=tag.name)
you passed a tag in URL so correct method would be :
tag = get_object_or_404(Tag, tag=tag)
But this will work only if, in your model,you have returned name of the tag as Unicode,Like this:
class Tag(models.Model):
name = models.CharField()
def __unicode__(self):
return unicode(self.name)
And if this still does not work then there might be a problem in TEPLATE_DIR setting in settings.py file. Then you have to share settings.py code for project file structure.
Source:stackexchange.com