Hi @noirbizarre and folks. This has also been a issue with me. I wanted to display data defined as @property and also transform the data to present it in a more pleasant way, with widgets, for example (in my specific case, I had a Batch object with a printProgress@property which I wanted to present as a progress bar.
So I made a patch.
This was the final result:
This is how the DataTable was defined:
class BatchDatatablesView(DatatablesView):
model = Batch
fields = {
'client':'client__name',
'start':'start',
'quantity':'quantity',
'credential':'credential',
'progress':showProgress,
}
credential is a @property of Batch.
showProgress is a callable which takes the row (Django ORM single object) and returns a string to be displayed. In this case:
Coverage decreased (-0.84%) when pulling fdf1e8659e73d51a394358591aa8df61462182f5 on bernardotorres:master into 347e74dcc08121d20f4cf942181d873dbe33b995 on noirbizarre:master.
Hi @noirbizarre and folks. This has also been a issue with me. I wanted to display data defined as
@property
and also transform the data to present it in a more pleasant way, with widgets, for example (in my specific case, I had aBatch
object with aprintProgress
@property
which I wanted to present as a progress bar.So I made a patch.
This was the final result:
This is how the DataTable was defined:
credential
is a@property
ofBatch
.showProgress
is a callable which takes the row (Django ORM single object) and returns a string to be displayed. In this case:The present patch does not enable searching from properties or callables, but I don't think it would be a good idea anyway.
I'm opening a pull-request.