Using Datatables with GenericRelation
jangeador opened this issue · 1 comments
jangeador commented
What would be the proper way to use datatables with GenericRelation
I tried to add the column content_object
but it tells me it is not reconized.
The column definitions on the model that are relevant are the following:
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey('content_type', 'object_id')
jangeador commented
I was able to do it by defining the TextColumn
explicitly. Here is the Datatable
definition:
class ScheduledTaskDatatable(Datatable):
content_object = columns.TextColumn('Device', sources=['content_object'])
class Meta:
columns = ['created_by', 'destination', 'scheduled_date', 'content_object']