I want to generate a table on my template, showing some data that I get from a method declared on my Task class
models.py
class Task(models.Model):
...
def check_if_finished(self):
resp = requests.get(
'http://my.rest.api/tasks/view/{}'.format(self.task_id))
resp_data = resp.json()
resp_finished = resp_data['task']['started_on']
if resp_finished is None:
return False
else:
return resp_finished
I know that there is no sense in calling a method on template, but what do I need to use to show this data?
template.html
{{ task.is_finished(task.task_id) }}