Skip to content
Advertisement

model IntegerField() to django-template with ordinal

I have a model with IntegerField()

JavaScript

And i would like it to display in a template with ordinal suffix.

JavaScript

I would like the floor output like this.

1st, 2nd, 3rd, 4th... 10th.. 12th.. 13th.. 15th...

Advertisement

Answer

You can use ordinal function from django.contrib.humanize package

Advertisement