icons let the template or resolve in the view?

21 views
Skip to first unread message

dk

unread,
Mar 3, 2015, 1:17:55 PM3/3/15
to django...@googlegroups.com
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?


felix

unread,
Mar 3, 2015, 1:43:15 PM3/3/15
to django...@googlegroups.com
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.

dk

unread,
Mar 3, 2015, 1:54:10 PM3/3/15
to django...@googlegroups.com
right now  I am not using models, form the database,  as concept I am pinging the computer,  and making a list of lists with the ip and if the machines is up or down, like this.

this is what I am passing to the template.
[ [up, machine1],[up, machine2],[down, machine3]  ]


should I pass something like
[ [path/to/icon, machine1], [path/to/icon, machine2], [path/to/icon, machine3] ]

or make and if then in the loop of the template and get the icons from there?

felix

unread,
Mar 3, 2015, 4:17:58 PM3/3/15
to django...@googlegroups.com
El 03/03/15 13:54, dk escribió:
right now  I am not using models, form the database,  as concept I am pinging the computer,  and making a list of lists with the ip and if the machines is up or down, like this.

this is what I am passing to the template.
[ [up, machine1],[up, machine2],[down, machine3]  ]


should I pass something like
[ [path/to/icon, machine1], [path/to/icon, machine2], [path/to/icon, machine3] ]

or make and if then in the loop of the template and get the icons from there?


I prefer the first way, just like you are doing now and then I would define a CSS class for UP and another for DOWN states to set the src property of the img tag (this is HTML) showing the state of the computer.


dk

unread,
Mar 3, 2015, 6:12:19 PM3/3/15
to django...@googlegroups.com
I didn't thing to put them as classes LOL.
thanks!

aRkadeFR

unread,
Mar 4, 2015, 4:25:21 AM3/4/15
to django...@googlegroups.com
If I get your request right, you want to display icons on each row
of your table.

In my projects, I'm using a font face. It's easy to use, scalable,
and you don't need any {% static %} templatetags in your templates.

Personnaly using icomoon to manage my icons.
https://icomoon.io/app/

Then you generate your font and include it in your html :)

Hope I helped you



On 03/03/2015 07:17 PM, dk wrote:
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?


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0a3fb3f1-1c24-4fa0-a7ed-4b21a2c99430%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages