fix the category list
This commit is contained in:
parent
6894a1bfba
commit
e63627ca4f
|
@ -5,13 +5,13 @@
|
|||
<body>
|
||||
<div id="content" class="flex">
|
||||
<h1>Music Shop</h1>
|
||||
{% if parent_category_list %}
|
||||
{% if category_list %}
|
||||
<ul>
|
||||
{% for parent_category in parent_category_list %}
|
||||
<li><a href="{% url 'category' parent_category.id %}">{{ parent_category.name }}</a></li>
|
||||
{% for category in category_list %}
|
||||
{% for category, sub_category in category_list.items %}
|
||||
<li><a href="{% url 'category' category.id %}">{{ category.name }}</a></li>
|
||||
{% for i in sub_category %}
|
||||
<ul>
|
||||
<li><a href="{% url 'category' category.id %}">{{ category.name }}</a></li>
|
||||
<li><a href="{% url 'category' i.id %}">{{ i.name }}</a></li>
|
||||
</ul>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
|
|
@ -12,13 +12,12 @@ def index(request):
|
|||
category_list = {}
|
||||
|
||||
for i in parent_category_list:
|
||||
category = Category.objects.filter(parent_category=i.id)
|
||||
category_list[i] = category
|
||||
category_list.update(
|
||||
{i: Category.objects.filter(parent_category=i.id)})
|
||||
|
||||
template = loader.get_template('webshop/index.html')
|
||||
context = {
|
||||
'category_list': category_list,
|
||||
'parent_category_list': parent_category_list,
|
||||
}
|
||||
return HttpResponse(template.render(context, request))
|
||||
|
||||
|
|
Loading…
Reference in New Issue