I have installed the djLint extension in VS Code and updated my settings file.
...
"[html][django-html][handlebars][hbs][mustache][jinja][jinja-html][nj][njk][nunjucks][twig]": {
"editor.defaultFormatter": "monosans.djlint"
},
"[django-html]": {
"editor.defaultFormatter": "monosans.djlint",
"editor.detectIndentation": true,
"editor.formatOnSave": true,
"editor.tabSize": 4,
"djlint.profile": "django" // This will apply your custom profile
},
...
However, when I create a new directory and set up a virtual environment (.venv), I get the following error when trying to save a Django template:
djLint is not installed for the current active Python interpreter. Install it with the `c:\Test\Django\Test\.venv\Scripts\python -m pip install -U djlint` command.
I want to avoid manually installing djLint in every virtual environment. Would appreciate any solutions or best practices. Thanks!
I have installed the djLint extension in VS Code and updated my settings file.
...
"[html][django-html][handlebars][hbs][mustache][jinja][jinja-html][nj][njk][nunjucks][twig]": {
"editor.defaultFormatter": "monosans.djlint"
},
"[django-html]": {
"editor.defaultFormatter": "monosans.djlint",
"editor.detectIndentation": true,
"editor.formatOnSave": true,
"editor.tabSize": 4,
"djlint.profile": "django" // This will apply your custom profile
},
...
However, when I create a new directory and set up a virtual environment (.venv), I get the following error when trying to save a Django template:
djLint is not installed for the current active Python interpreter. Install it with the `c:\Test\Django\Test\.venv\Scripts\python -m pip install -U djlint` command.
I want to avoid manually installing djLint in every virtual environment. Would appreciate any solutions or best practices. Thanks!
Share Improve this question asked Mar 16 at 13:21 I'mSRJI'mSRJ 3231 silver badge11 bronze badges1 Answer
Reset to default 0After exploring the djLint VS Code extension repository, I found a way to make djLint
available across all virtual environments without manually installing it in each one.
Using uv
to Install djLint
Globally
Instead of installing djLint
in every virtual environment, I use uv
, which is a faster and more efficient package manager. Here's how to set it up:
1. Install djLint
using uv
uv tool install djlint
2. Update settings.json
in VS Code
Modify your VS Code settings.json
file to disable virtual environment dependency and specify the correct Python path:
{
"djlint.useVenv": false,
// Linux Path
"djlint.pythonPath": "/home/user/.local/share/uv/tools/djlint/bin/python"
// Windows Path
"djlint.pythonPath":"C:\\Users\\SRJ\\AppData\\Roaming\\uv\\tools\\djlint\\Scripts\\python"
}
If anyone has a better approach, feel free to share!
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744599384a4583088.html
评论列表(0条)