cat models.py from django.db import models from datetime import datetime def GetInHMS(seconds): hours = seconds / 3600 seconds -= 3600*hours minutes = seconds / 60 seconds -= 60*minutes return "%02d:%02d:%02d" % (hours, minutes, seconds) class SSwAlive(models.Model): id = models.IntegerField(primary_key=True) sw = models.CharField(max_length=255, blank=True) ctime = models.IntegerField(null=True, blank=True) utime = models.IntegerField(null=True, blank=True) is_deleted = models.IntegerField(null=True, blank=True) def __unicode__(self): return "{0} {1} {2}".format(GetInHMS(self.utime-self.ctime),datetime.fromtimestamp(self.ctime),self.sw) class Meta: db_table = u's_sw_alive' from django.shortcuts import render_to_response from soffice.app_ping.models import * cat views.py def ping(request): res = SSwAlive.objects.filter(is_deleted=0) return render_to_response('switch.html',{'res':res}) cat switch.html {%for uu in res%} {{uu}} {%endfor%} The question is how do I get the uu variable columns separately to create a normal table. If uu.sw is done, this column is appropriate, and all the others that I return from models.py how to get them? I need to separately receive:
GetInHMS (self.utime-self.ctime), datetime.fromromstastamp (self.ctime)