Python/Django development in Windows Terminal

Well, I decided to write a small Django app, and as Windows is used at our workplaces and I've gotten used to linux, two problems arose:

  • You need to call admin every time you install any program
  • WSL is rather limited

So, after some tinkering, tries, and errors I came to a minimal configuration, which I'll describe in this article. Hope, it helps someone somehow. :) I'm also new to programming and Django in particular, so it took me a while to find an optimal setup.

My requirements are very simple:

  • Terminal-based workflow
  • A few steps to setup
  • Reproducible, if something goes wrong

I ended up with the following:

  • Ubuntu in WSL2, just the default
  • Windows Terminal, why not
  • tmux is used with two or three windows: neovim, runserver, find something/look in the database
  • neovim + kickstart
  • Python 3 + pip, nothing special
  • GitHub Projects to have a task list
  • git to track versions when I complete a task

For the current project I use SQLite, but it shouldn't be an issue with any other database.

The only thing worth discussing here is neovim, so let's dive into that.

First I tried emacs-nox as I use emacs for writing texts. But for programming emacs is too much with its functions, and windows management becomes a problem as well: it creates lots of service buffers. On the other hand, neovim + Telescope is a nice solution for windows management, neovim has just the functions I need for editing, so it's a lot easier to get into the 'flow state' for programming.

By the way, I don't use a language server for Python, but I use an emmet language server to write HTML faster. I don't use LSP for Python just because I learn Django and Python and I need first of all to understand, so I look into documentation and try to write when I'm sure what I'm doing. Django requires writing very little text, but switching between (or having them on one screen) models, forms, urls, and views is critical. And neovim does that pretty well.

Again, due to WSL limitations, I was able to use neovim binary only from the official site: AppImage didn't work for me. And you need a fresh neovim version for Lazy, which is used by kickstart.

You can find great ways to use tmux and also bind neovim and tmux together, I just keep it simple.

Someone could use docker, but Python's virtual environment works pretty well for me, I was able to copy it to the linux machine, mostly with pip freeze and pip install -r. And the app just works.

@Konstantin Ovchinnikov
Tags: #python #vim

Comments