I keep getting this error message:
Reverse for 'tagged' with arguments '('',)' not found. 1 pattern(s) tried: ['\^tag/\(\?P(?P[^/]+)\[\-\\w\]\+\)/\$$']
when trying to load my base.html, because of an anchor tag. I have looked at other posts with the same issue, but I still don't know where I'm going wrong.
views.py
class TagIndexView(TagMixin, ListView):
template_name = 'post/index.html'
model = Post
paginate_by = '10'
context_object_name = 'posts'
def get_queryset(self):
return Post.objects.filter(tags__slug=self.kwargs.get('slug'))
def tagged(request):
return render(request, 'blog/tagged.html', {'title': 'Tagged'})
urls.py
path(r'^tag/(?P<slug>[-\w]+)/$',TagIndexView.as_view, name='tagged')
base.html
The anchor tag:
<li class="list-group-item"><a href="{% url 'tagged' tag.slug %}">Tags</a></li>
But I keep getting a NoReverseMatch. In the anchor tag I have tried "tag.slug", "tag.id", "tag.pk" and some others.