Forums

Website not showing changes to Django Templates

Hey, I couldn't find the answer I needed in the archives, so I'm making this post here. I've updated my base template, which all other templates extend and get their basic formatting from. The thing is, my live website is not showing the changes. I've reloaded the web app but nothing has changed. Any changes to my .py files are noticed and the live site is updated accordingly. Any code wizards know a solution? I'm sure it should be pretty simple. I appreciate you guys.

in your settings- how do you specify that path to the templates? and do changing non-base templates work?

This is how I specify the path to the templates in the settings:

Begin Code

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

TEMPLATES_DIR = os.path.join(BASE_DIR, 'templates')

End Code

And yes, regardless of whether or not the other templates are changed, there is no difference shown on the site-even if I completely break the code.

[edit by admin: formatting]

just to confirm- what's the path/location of your settings file? and what is that path you specified in your wsgi.py?

the path of my settings file is :

/home/littlePLANET/.virtualenvs/django2/Blog/coolSite

The path that I specified in my wsgi.py file is:

(path to my manage.py file) path = '/home/littlePLANET/.virtualenvs/django2/Blog'

if path not in sys.path:

    sys.path.append(path)

(path to my settings.py file) os.environ['DJANGO_SETTINGS_MODULE'] = 'coolSite.settings'

Everything loads, and everything else is functioning on my site at "littleplanet.pythonanywhere.com". The odd thing is that nothing is refreshing as far as the html in my templates goes. Obviously there seems to be an older version of my templates that either django or the pythonanywhere api is referring to. Why could this version of my templates not be getting updated?

[edit by admin: formatting]

Have you checked to see that your browser isn't just showing you the cached version it stored rather than requesting the new one from your site? You can force a 'hard-reload' in most browsers by doing Ctrl+Shift+R (Apple is Command+Shift+R).

You could also try opening your browsers Dev tools (Firefox and Chrome should be Ctrl+Shift+I I believe, or just right-click the page and select "Inspect Element"). Then navigate to the "Network" tab, on that tab, there should be a checkbox for "Disable cache", select it and (keeping Dev Tools open) refresh the page. That will force your browser to request the latest version of files from the server rather than using a cached version.

I had a similar problem to you once and it took me hours to figure out that's what it was... Hopefully, this helps solve your issue!

Perhaps you could give us an example of a visible thing that we can see on your website which indicates that a template change is not being applied? If you do that, and also give us permission to look at your code, then perhaps we can help you work out what's going on.

Well the answer was simple, thank you guys for all your help. I had two copies of my templates folder, one at /home/littlePLANET/templates and another at my django app root directory /home/littlePLANET/.virtualenvs/django2/Blog/templates. Of course since the pythonanywhere api is looking at the first templates directory, it is oblivious to the other folder. You get so used to programming a certain way on the development server I guess muscle memory takes over at times. Thanks guys. Hopefully this helps out someone in the future.

So how did solve the template? I have also the same two template files What should I do?

@MathKH We need more details to help you.