Я знаю, что в интернете много решений этой проблемы, но что-бы я не пробовал получается ошибка -
Reverse for 'get_category' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['category/(?P<alias>[^/]+)'].
template
<a href="{% url 'get_category' category.alias %}">
views
def products(request, alias):
try:
product = Items.objects.get(alias=alias)
title = product.name
except:
raise Http404("Объект не найден")
context = {
}
return render(request, 'product/product.html', context)
def get_category(request, alias):
try:
category = Category.objects.get(alias=alias)
products = Items.objects.filter(category=category)
except:
raise Http404('Объекты не найден')
context = {
'products': products,
'category': category,
}
return render(request, 'popular/popular.html', context)
urls
url(r'^$', views.popular, name='popular'),
url(r'^products/(?P<alias>[^/]+)', views.products, name='product'),
url(r'^category/(?P<alias>[^/]+)', views.get_category, name='get_category'),