You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here are some insights of my personal experiences installing the django-language-server in Neovim.
As described in the documentation, the basic setup with Lazy.nvim involved starting with this :
-- basic setup from the documentation
{
"joshuadavidthomas/django-language-server",
dependencies= {
"neovim/nvim-lspconfig",
},
config=function(plugin, opts)
vim.opt.rtp:append(plugin.dir.."/editors/nvim")
require("djls").setup(opts)
end,
}
But it didn't work right away with the server being installed globally, in my lsp logs I was getting errors about modules that cannot be found to initialize the Django project :
[ERROR][2025-04-18 09:22:46] ...lsp/handlers.lua:562 "Failed to initialize Django project: ModuleNotFoundError: No module named 'backports'"
I guess this was because the process was unable to locate the packages in my project virtual env, even though I had launched nvim with my venv sourced. Maybe this is linked to this issue #69 ?
So the first thing I had to do is to install django-language-server in my venv as a project dev dependency.
Then I still had en error at startup :
[ERROR][2025-04-18 09:39:14] ...lsp/handlers.lua:562 "Failed to initialize Django project: ImproperlyConfigured: Requested setting LOGGING_CONFIG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings."
Pretty self explanatory : I need to set the DJANGO_SETTINGS_MODULE env variable for the server process. So I updated my configuration to do so.
Here is my final configuration, I don't know if its the best, but it works right now. I would be happy to hear your personal thoughts and tips about it. Maybe I'm missing something !
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Here are some insights of my personal experiences installing the
django-language-server
in Neovim.As described in the documentation, the basic setup with Lazy.nvim involved starting with this :
But it didn't work right away with the server being installed globally, in my lsp logs I was getting errors about modules that cannot be found to initialize the Django project :
I guess this was because the process was unable to locate the packages in my project virtual env, even though I had launched nvim with my venv sourced. Maybe this is linked to this issue #69 ?
So the first thing I had to do is to install
django-language-server
in my venv as a project dev dependency.Then I still had en error at startup :
Pretty self explanatory : I need to set the
DJANGO_SETTINGS_MODULE
env variable for the server process. So I updated my configuration to do so.Here is my final configuration, I don't know if its the best, but it works right now. I would be happy to hear your personal thoughts and tips about it. Maybe I'm missing something !
Beta Was this translation helpful? Give feedback.
All reactions