Hi there,
Is just started to work with django-tables and I think it's a great
app! One question (maybe I missed it in the information). Is it
possible to call a model method through django-tables?
See example below. Is it possible to call the get_product_url in the
model below so I can use the url in one of the columns?
I have tried it with
{% for row in rows %}
{{ row.get_product_url }}
{% endfor %}
and put get_product_url in my tables.py file but that doesn't seem to
work.....
----models.py-----
from django.db import models
class Dixons(models.Model):
name = models.CharField(max_length=200)
price = models.IntegerField()
link = models.CharField(max_length=300)
description = models.TextField(blank=True)
category = models.CharField(max_length=100)
def __unicode__(self):
return self.productname
class Meta:
ordering = ['name']
def get_product_url(self):
return '/shop/product/%s/' %
self.id