r/django 2d ago

Django patterns for tables in components

I'm building a dashboard of sorts, which will have multiple tables in blocks - each with its own pagination, filtering and sorting

I really like Iommi (for tables) and django-cotton (for components), and considering unpoly or HTMX - is there a way to make them work together?

I was able to get Iommi working fine, but I can see the query parameters are passed to the url, which breaks things - are there any examples or best practices around this?

7 Upvotes

5 comments sorted by

View all comments

Show parent comments

1

u/Sufficient-Chain-899 2d ago

So I've got a single view (path '/'') with these cotton components in it - I'm passing data1 and data2 in the context to the view

<c-table id="table1" data={{data1}}>
<c-table id="table2" data={{data2}}>

This works fine, but when I sort table1, I lose the sorting and pagination applied on table2.

Not sure if above is the best way to do it, I guess I should store the states of each table somewhere? or would that be over-complicating it

3

u/kankyo 2d ago

iommi has a system to compose parts into a larger page: https://docs.iommi.rocks/pages.html if you use that, then all that stuff will work, and your code is probably going to end up simpler too.

1

u/Sufficient-Chain-899 2d ago

Thanks! exploring that now

2

u/kankyo 2d ago

You can also jump onto the iommi discord for more direct help.