Django built-in templates tags gets unformatted when I save my html file in VS-code

239 Views Asked by At

I'm using django built-in templates tags which are {% load static %} {% extends 'base.html' %} etc. so whenever I'm saving my document by pressing ctrl+s the formatting which should be gets disturbed which causes errors:

Unclosed tag on line 1: 'block'. Looking for one of: endblock.

enter image description here

before saving the document the editor looks something like this: enter image description here

but as soon as I save my document it becomes like this which results in the above mentioned error enter image description here

any solution for that? maybe add or remove some formatting extensions?

1

There are 1 best solutions below

0
Jayant Nigam On

Okay so I tweaked around some settings.json in vscode and found my solution: add the following lines

"[django-html]": {
    "editor.quickSuggestions": {
      "other": true,
      "comments": true,
      "strings": true
    },
    "editor.defaultFormatter": "batisteo.vscode-django"
  },

enter image description here

My assumption to this solution is that, earlier this [django-html] settings was not instantiated so by default a django-html template was getting formatted through [html] settings as seen in the image below (pls correct me if my assumption is wrong).