How to get liveserver to render django templates?
I've been messing around with a tutorial site, and I found that my VS Code LiveServer plugin doesn't work properly when I try to open Django templates. The CSS I applied is missing (although everything renders correctly in my local development sever), and the template language code is actually printed to the screen rather than executed (see image below). My liveserver plugin appears to be working with html files outside of Django.
(1) Right now I'm right clicking and selecting "Open with Liveserver." Is this wrong for Django? The liveserver docs recommend trying to "visit the Actual Server Address: http://localhost/[workspace], not the VS Code extension's Live Server Address: http://127.0.0.1:5500/". I tried including the file path in place of [workspace], but no luck. What do I do here?
(2) I saw in another thread where someone recommended their own solution, here. I'm not sure where I'm supposed to run the './manage.py livereload' command, but it's not working in command prompt. What is the difference between './manage.py' and 'py manage.py'? And will this solution be any better than the VS Code plugin?
Solution 1:
I have had the same problem as you, and managed to get it working with the link you included in the point (2) of your post. You may have gotten sorted by now, but I thought I'd post here incase.
First I went to my console and ran:
pip install livereload
which installed successfully. Then I added 'livereload' to my installed apps in my settings.py file. E.g...
INSTALLED_APPS = [ ... 'livereload', ... ]
Then I went to the directory containing my manage.py file on the terminal, and ran
./manage.py livereload
and this provided me with a link to a live update server. Previously I had been running a server with "python manage.py runserver", so this is to replace that command. Now when I save any changes I make in my IDE, they update live on the browser. Sorry that I haven't included any screenshot images for clarity, I wasn't able to for some reason.