The move to PythonAnywhere

Feb. 19, 2024

As you may have seen from a previous article, I have today moved my hosting for this Wagtail site to PythonAnywhere. This process wasn't overly problematic, although there were a few things worth sharing as a part of it:

File space on the free tier

I tried to do as much on the free tier over the last few weeks as possible, but this just added a lot of pain. There wasn't really enough space to run pip install -r requirements.txt in one go, meaning not only did I have to cancel and clear some of the cache files (rm -rf ~/.cache) but that I also ended up wasting time debugging missing modules from Wagtail which were fixed by just reinstalling it.

Just use venv

For some reason I don't comprehend, I did not use venv when I first set things up, meaning I installed a load of things I then had to manually uninstall again (rather then just deleting and rebuilding a venv). This was foolish, and it is part of the steps on their Django setup docs https://help.pythonanywhere.com/pages/DeployExistingDjangoProject/

WSGI tweaks

I had to do some tweaks to the WSGI that pythonanywhere supplies. These are on the Django setup docs, so not too bad, just requires tweaking paths and filenames a little to get right.

Reload, Reload, and Reload

Remember things wont show straight away in a lot of cases, you will need to reload in the PythonAnywhere UI after changes.

Deploy runner

This is something I have gotten into the habit of doing, as keeps things consistent, reliable, and documented (by comments). I have a deploy-runner.py script which handles git pull, manage.py commands, and any maintenance steps like clearing caches. This just takes some of the repetitive (and forgettable) steps away when I may only deploy things now and then.