Reputation: 314
I have a listview
in my Django's project like:
class KaoiroView(ListView):
template_name = 'main/show-kaoiro.html'
queryset = Kaoiro.objects.all()
context_object_name = 'kaoiro'
paginate_by = 10
where Kaoiro
has one column called
checkTime = models.BigIntegerField()
in models.py
.
this checkTime
is an unixtime
like one big number.
I would like to convert this time when user get
above page from my views.py
, but because I'm using a listview
I don't know how to access this data
Upvotes: 0
Views: 88
Reputation: 634
you can create a new property in your model class such as :
this property is called derived property you can use any formula or code here to calculate new value.
class kaoiro(models.Model):
...
...
checkTime = models.BigIntegerField()
@property
def normal_time(self):
ct = self.checkTime
## do something with ct
return ct
you can use normal_time
as any other property of your class.
Upvotes: 1