Added links to child categories

This commit is contained in:
Oliver Walters 2017-03-26 10:23:22 +11:00
parent ef8cfa794f
commit 3f81046a26
2 changed files with 10 additions and 1 deletions

View File

@ -4,6 +4,10 @@
{% endfor %}
{{ category.name }}
<br><br>Children:<br>
{% for child in children %}
<a href="/part/category/{{ child.pk }}">{{ child.name }}</a><br>
{% endfor %}
<br>

View File

@ -18,5 +18,10 @@ def category(request, category_id):
# Find the category
cat = get_object_or_404(PartCategory, pk=category_id)
# Child categories
childs = PartCategory.objects.filter(parent = cat.pk)
return render(request, 'part/category.html',
{'category': cat})
{'category': cat,
'children': childs
})