Humanize intword

Hi everyone,

I need help with the humanize library. I want to change how the numbers are displayed. For example, 1,000,000 to 1 million. Or 10,000 to 10k.

https://docs.djangoproject.com/en/4.0/ref/contrib/humanize/

Looking at that doc, it seems like I need to add it in a template. But what if I just want to use it inside a regular python function? Is this possible? If so, how do I do it?

image

This logic only works if the number is over 1 million. But I want it to work if it’s less than that number. Like 10,000 => 10k or 500,000 => 500k.