Tuesday, March 3, 2015

Re: icons let the template or resolve in the view?

El 03/03/15 13:17, dk escribió:
I will be populating a table with information of computers and I would like to display an icon in front of each line of the table. might change depending of the machine,  should I let the view handle that with and if then and later on use static to resolve the file path?
or should I make that if then and resolve the path by myself in the view?


I'm a newbie but here I go:
I think that it depends on how machines and icons are related. If each machine has a particular icon you should create a field in your computer model to handle it, an ImageField for instance. If you have  icons representing groups of computers then you could also use CHOICES in the model or even use an If tag in the template.
Views process the info you will show on templates, being the latest in charge of how to display it.

Cheers,
Felix.

No comments:

Post a Comment