+ 1

How to display product categories using css, with django templates

Django frameworks

13th Jan 2020, 10:41 AM
Aksam Lwanga
Aksam Lwanga - avatar
2 ответов
+ 4
Use {% for category in categories %} {% endfor %} template tag. Inside such a loop you can place a category HTML. {{ category.name }} for example will give category instance's attribute. CSS works as usually in templates. Although you would need to link a CSS file by {% static 'appname/css/style.css' %}. Also it's necessary to load static tag template library in the beginning of your template. I.e. {% load static %} if I am not mistaken.
14th Jan 2020, 8:41 AM
SergeiRom
+ 3
And of course you should pass categories into the template context by means of a view or context processors.
14th Jan 2020, 9:11 AM
SergeiRom