Django – Making a Django website more human-like using Humanizer

In this article, we will see what is humanizer and how to use it in Django. Humanizer is a filter in Django that is used to add human touch to a project. It is one of the best filters of Django.

Humanizer is used to convert numbers from numerical figures to words, or adding comma between numbers, or to convert numbers to million or billion. Let's take an example and understand how to use it.


Create a Django project and an app .

Configure the project urls −

from django.contrib import admin
from django.urls import path,include

urlpatterns = [

Here we set up our urls for our app.

In App's, add the following −

from django.urls import path,include
from . import views
urlpatterns = [
   path('', views.home, name="home")

In app's url, we rendered our view.

Create a templates folder and configure it in

      'BACKEND': 'django.template.backends.django.DjangoTem plates',
      'DIRS': [os.path.join(BASE_DIR, 'humanizeproj/templates')],
      'APP_DIRS': True,
      'OPTIONS': {
         'context_processors': [

Here we defined our template folder for better accessing of templates.

Also, don't forget to add home.html in it. Don't write anything inside it for now.

In, add your app and filter contrib −

   # This is needed to add
   "humanizeproj", # this is my app name

Here we added our app and module contrib.

In, add the following lines −

from django.shortcuts import render

# Create your views here.
def home(request):
   return render(request,"home.html")

Here we rendered our frontend which is home.html.

In home.html, add −

<!DOCTYPE html>
      {% load humanize %}
      <h1>Numbers(apnumber function) :</h1>
      {{"1" | apnumber}}<br>
      {{"2" | apnumber}}<br>
      {{"10" | apnumber}}<br>
      <h1>integer comma:</h1>
      {{"1000" | intcomma}}<br>
      {{"200000" | intcomma}}<br>
      {{"10000000" | intcomma}}<br>
      <h1>integer word:</h1>
      {{"1000000000" | intword}}<br>
      {{"20000000000" | intword}}<br>
      {{"10000000" | intword}}<br>

apnumber is used to convert number to word, intcoma is used to add comma between numbers, and intword is used to convert integers to million or billion.