You can use djlint to lint and format templates.

pip3 install djlint