I searched but couldn't find similar question, so I apologies if this was already answered. Now let's get on topic. I have a model with @property values (3 of them). All of them works and one just return empty and I can't find a problem. Here is the part of model:
@property def case_number(self): ''' An formatted number officially designating this case. ''' s = u'%012d' % self.pk return s[:3] + '-' + s[3:6] + '-' + s[6:9] + '-' + s[9:] @property def case_id(self): ''' An formatted string, consisting of the prefix NCDAC- and the case number, officially designating this case. ''' return 'NCDAC-' + self.case_number @property def due_date(self): margin = self.report_date + datetime.timedelta(days=30); if timeuntil(margin) <= datetime.timedelta(days=1): return 'today' elif timeuntil(margin) < 0: return 'overdue' else: return timeuntil(margin).split(', ')[0] And here is template part that displays DB results in rows:
{% for case in sent_cases %} <tr> <td> <a href="{% url "case-detail" case.pk %}"> {{ case.case_number }} </a> </td> <td>{{ case.get_agency_display }}</td> <td>{{ case.report_date }}</td> <td> {% if case.status == "D" %} <i class="icon-minus-sign"></i> No {% else %} <i class="icon-ok-sign"></i> {{ case.ts_submitted|date:"d M Y" }} {% endif %} </td> <td>{{ case.due_date }}</td> </tr> {% endfor %} Everything is working except {{ case.due_date }}. It's just empty block. Any idea why this is happening?
Thanks.
UPDATE: Ok I tried just to return "something" and it's working. I have a error bellow - for some reason it doesn't rise Exception though. self.report_date is defined as report_date = models.DateField(verbose_name='Report Date') and I'm trying to get how much days is left untill report_date + 30days.
timeuntil(margin).split(', ')[0]this return some value??timeuntil(margin).split(', ')[0]with pure string like 'something' and still nothing was echoed in template.timeuntil(margin).split(', ')[0]try to print out the return value in funcdue_datemay be your logic is wrong and it is actually returning an empty string.