I do not use formatters when writing django code... but even if you want to use it, use a dedicated django/python formatter instead of a JS-orientrd formatter like prettier.
I faced this same problem when using prettier and eventually I had to disable it when writing django.
Ok Thank you so much
Habib
Doragonsureiyā
Charly
Maxim
Weslen
Nima
clouded
Luis
HAJI MASTAN
George B
cj
Hima
Arsalan
Simon