<filename>example/app/templatetags/sqlformat.py
from django import template

import sqlparse

register = template.Library()


@register.filter
def sqlformat(sql):
    """
    Format SQL queries.
    """
    return sqlparse.format(str(sql), reindent=True, wrap_after=120)

<filename>example/app/templatetags/sqlformat.py
from django import template

import sqlparse

register = template.Library()


@register.filter
def sqlformat(sql):
    """
    Format SQL queries.
    """
    return sqlparse.format(str(sql), reindent=True, wrap_after=120)

Format SQL queries.