django_serverside_datatable icon indicating copy to clipboard operation
django_serverside_datatable copied to clipboard

How to deal with model property-functions

Open odoublewen opened this issue 2 years ago • 1 comments

@umesh-krishna Can you think of any clever way to make properties available in the server-side data table view?

I.e. say my models look like:

class Bar(models.Model):
    foo = models.ForeignKey(Foo, ....)

class Foo(models.Model):
    field1 = ...
    field2 = ...

    @property
    def number_of_bars(self):
        return Bar.objects.filter(foo=self).count()

How can I get number_of_bars into the datatable?

odoublewen avatar Mar 11 '22 23:03 odoublewen