adamchainz / django-rich

Extensions for using Rich with Django.
MIT License
121 stars 10 forks source link

Add tabulate() #229

Open smithdc1 opened 1 month ago

smithdc1 commented 1 month ago

Fixes #215

adamchainz commented 3 days ago

Hey David,

I had a go at hacking around on this a few days ago. Sorry I didn't write a message until now!

I liked your start, thank you very much. I still want to merge this, and I think it's nearly there. I would prefer to avoid chaining the values_list onto the queryset in the model iterator branch though, and to only iterate/fetch once. I have some ideas on how to do this, hopefully I'll find some more time again soon.

But until then maybe you can review what I did? I would like another pair of eyes on it, to check I'm not going in a strange direction!

smithdc1 commented 2 days ago

Hi Adam 👋

Reading your edits is a rather valuable learning experience for me. In particular, seeing queryset._iterable_class was a 'penny drop' moment for me. I didn't know about this and therefore I was writing tests for different queries and seeing what the output was. I learned that I should have been looking at how QuerySet determines the type of iterable / output.

(I still don't fully understand type hints😄 )

maybe you can review what I did?

Of course! I'm on holiday next week as it's half term here. I'll put it to the top of my list for when I get back.