[Answer]-Trying to insert a new column with a list of foreign field in django_tables2

1๐Ÿ‘

โœ…

If you want (1:N instead of N:1) to concatenate all related models in the table cell try to do this in your model layer by setting property, something like this:

class RepairDetail(models.Model):
    # ...

    @property
    def service_reports_list(self):
        return self.servicereport_set.all()

Define your own column (inherit tables.Column) and override render method

Add it to your table class:

class RepairDetailTable(tables.Table):
    # ...
    service_reports_list = YourOwnColumn(some_kwargs)
    # ...
๐Ÿ‘คmadzohan

Leave a comment