Reformat python tags in HTML files



I am learning Django. In the project, I have to write in HTML files
python code in tags like {% %} {{ {}}. The problem is that when I
reformat code, it seems that the IDE does not understand those tags and
it fails to format them.

Is there any IDE or way to reformat python tag in HTML files?

Thank you !