Spaces:
Runtime error
Runtime error
| import django_tables2 as tables | |
| from .models import Product | |
| from django.utils.safestring import mark_safe | |
| class ProductTable(tables.Table): | |
| url = tables.Column(verbose_name='URL') | |
| def render_url(self, value, record): | |
| if value: | |
| link = f'<a href="{value}" target="_blank">{value}</a>' | |
| return mark_safe(link) | |
| else: | |
| return '' | |
| class Meta: | |
| model = Product | |
| template_name = "django_tables2/bootstrap.html" | |
| fields = ("id","product_id","title", "ingredients", "url", "store_name") | |
| attrs = {"class": "table table-striped table-bordered table-hover"} | |
| order_by = ('id',) |