Update 2
After solving the issues I raised in Update 1 using this tutorial, the problem still persisted. Maybe everything I said in Update 1 was entirely wrong or maybe Update 1 and 2 complimented each other.
It now seems that I have managed to permanently fix the problem by removing these lines of code - request.META.get("REMOTE_ADDR")
and requests.get('http://ip.42.pl/raw').text
. Many months ago these two lines of code served a purpose and caused no issue. I don't know why these two lines of code started causing an issue. But thankfully I no longer needed them, so it was safe to delete them.
Update 1
It turns out the original solution I proposed was wrong. I realised my problem was to do with Windows Security. I can only assume that one of the default Microsoft updates impacted the Windows Security.
Something happened which meant that 'Run quick scan' and 'View security dashboard' did not work any more.

I was getting the 'open this windowsdefender link'.

As a temporary fix I have discovered that sometimes just clicking 'Ok' on the error message resolves the issue. But I am actively trying to find a thorough, proper solution to the problem.
Original Comment
I have a Django Projects folder where I keep the latest version of my website and backups of my website from previous days, weeks, months and years. This folder had ballooned in size to 13.9GB and it contained 310,165 Files.
This was causing the problem. So I had to create a Django Projects Recent folder and a Django Projects Old folder.