Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML Files recognized as Django template in VS Code #33

Closed
cdrrr opened this issue Mar 31, 2019 · 25 comments
Closed

HTML Files recognized as Django template in VS Code #33

cdrrr opened this issue Mar 31, 2019 · 25 comments

Comments

@cdrrr
Copy link

cdrrr commented Mar 31, 2019

If Django extension is installed in VS Code, all HTML files are recognized as Django files and displays a wrong icon.

image

@dustinmichels
Copy link

I am having problems with this, too.

Configuring the "file.associations" settings seems like the right approach, but even when I add the suggested snippet to my settings, all HTML files get recognized as "django-html."

"files.associations": {
    "**/templates/*.html": "django-html",
    "**/templates/*": "django-txt",
    "**/requirements{/**,*}.{txt,in}": "pip-requirements"
},

Shouldn't this snippet cause only html files in a templates/ folder to be recognized as "django-html"? Am I missing something?

@dustinmichels
Copy link

Update: These settings seem to work for my needs.

  "files.associations": {
    "*.html": "html",
    "**/templates/**/*.html": "django-html"
  },

Would this be a better configuration to include in the README?

@washie254
Copy link

washie254 commented May 29, 2020

Update: These settings seem to work for my needs.

  "files.associations": {
    "*.html": "html",
    "**/templates/**/*.html": "django-html"
  },

Would this be a better configuration to include in the README?

This Totally worked for me. -> in case you're lost

  1. access settings use Ctrl+,
  2. search file.association on the search bar
  3. select ' edit in settings.json '
  4. append this section in "files.associations":
 "*.html": "html",
"**/templates/**/*.html": "django-html"

@Networkqueen
Copy link

Thank you so much this worked for me

@Ritik-Creates
Copy link

Thanks.... I was getting messed up in my server due to this

@PianoHallvard
Copy link

Excellent! This has bugged me for months
I just uninstalled django

@antonygatua
Copy link

Thanks works for me too!

@Bishwas-py
Copy link

I want this problem in my VSCODE. How to get this problem, please?

@enricoreich
Copy link

enricoreich commented Oct 5, 2020

So, after vscode is recognizing django templates as django templates, how do I get all the html and emmet feature back? I mean features like html intellisense, code completion and formatting etc...

for formatting I tried in settings.json:

"[django-html]": {
    "editor.defaultFormatter": "vscode.html-language-features"
  }

but it does not work. I don't want to install additional extensions like beautify or prettier because they don't support django templates and are making formatting even worse. But it would be enough for me to get IntelliSense and code completion back. Any ideas? Thanks!

@AlessandroCF
Copy link

Thank you for your very valuable advice, it helped me a lot.
Best regards

@zia-ashraf
Copy link

zia-ashraf commented Oct 11, 2020

I thought at last i got the answer.BUT,
"files.associations" comes up when i search it in settings but, ' edit in settings.json ' option is not present for this one.
It just shows:
image

@Pixelshot
Copy link

I thought at last i got the answer.BUT,
"files.associations" comes up when i search it in settings but, ' edit in settings.json ' option is not present for this one.
It just shows:
image

You can insert them individually as below

Screenshot 2020-11-15 230057

@eykanal
Copy link

eykanal commented Jan 27, 2021

Solved in this thread. In summary:

  1. Install Beautify by HookyQR (to allow modifying file type formatters)
  2. Add the following to your user settings file:
"beautify.language": {
    "html": [
        "htm", "html", "django-html"
    ]
},

@eriker75
Copy link

eriker75 commented Mar 7, 2021

Thank you very much

@VladIftime
Copy link

So, after vscode is recognizing django templates as django templates, how do I get all the html and emmet feature back? I mean features like html intellisense, code completion and formatting etc...

for formatting I tried in settings.json:

"[django-html]": {
    "editor.defaultFormatter": "vscode.html-language-features"
  }

but it does not work. I don't want to install additional extensions like beautify or prettier because they don't support Django templates and are making formatting even worse. But it would be enough for me to get IntelliSense and code completion back. Any ideas? Thanks!

I found that you have to add the following line to VSCode's settings.json:
"emmet.includeLanguages": {"django-html": "html"}

This fixed it for me, hope it helps.

@fedepuleio
Copy link

I thought at last i got the answer.BUT,
"files.associations" comes up when i search it in settings but, ' edit in settings.json ' option is not present for this one.
It just shows:
image

You can insert them individually as below

Screenshot 2020-11-15 230057

you made my day, THANKS!!!!

@Fate1405
Copy link

*.html
**/templates/**/*.html

In case you were too lazy to type it out lmao.

@Seek4samurai
Copy link

Update: These settings seem to work for my needs.

  "files.associations": {
    "*.html": "html",
    "**/templates/**/*.html": "django-html"
  },

Would this be a better configuration to include in the README?

This is the perfect solution. Hands down.

@sammanamgain
Copy link

just uninstall Django in extension problem solved

@batisteo
Copy link
Contributor

batisteo commented Feb 9, 2022

Thanks for your patience. I found the undocumented filenamePatterns key (see commit) and it should work as expected now.

🗑️ You can remove the file associations in your settings, for both django-html and html, as this extensions shouldn’t be that eager with HTML files.

I hope it will reduce the frustration of you guys and new comers.

@michael-hll
Copy link

Update: These settings seem to work for my needs.

  "files.associations": {
    "*.html": "html",
    "**/templates/**/*.html": "django-html"
  },

Would this be a better configuration to include in the README?

This worked for me... Thanks a lot.

This worked for me... Thanks a lot.

@batisteo
Copy link
Contributor

@michael-hll Have you updated the extension and tried to remove the html file associations?

@DanSiGo
Copy link

DanSiGo commented Jul 3, 2023

Update: These settings seem to work for my needs.

  "files.associations": {
    "*.html": "html",
    "**/templates/**/*.html": "django-html"
  },

Would this be a better configuration to include in the README?

this worked for me, but wrote "/templates//*.html": "html" instead

don't know why to use "django-html", but didn't get intellisense with it

@vedika-gupta
Copy link

vedika-gupta commented Jul 12, 2023

This Totally worked for me. -> in case you're lost

  1. access settings use Ctrl+,
  2. search file.association on the search bar
  3. select ' edit in settings.json '
  4. append this section in "files.associations":
 "*.html": "html",
"**/templates/**/*.html": "django-html"

Hey! This worked for me but I am still not able to use doctype file using shift + 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests