Django Templates Not Updating with CSS Changes - django

I am currently working on a project using Django and Django Templates.
For this project, I had to adjust the design and tweak some of the CSS in the static files.
I had previously been running the server on a Google profile for a while.
However, after completing my changes, and running the server on that same Google profile, none of the changes I've made was displayed.
When I run the server on a guest account, change my Google profile, or run the server on Safari, the changes appear.
I'm curious to know why this is happening.
Any ideas?

Related

Why is my debug Django server takes so long to load on my localhost? I'm using Django, django-compressor, django-libsass and bootstrap

I have a problem with developing a Django website. I started out with using CDN Boostrap and JS as recommended in Boostrap 5 docs but then I wanted to customize the CSS, so I changed the setup to compile Bootstrap's source scss files with django-libsass. I followed the installation guides for django-libsass and django-compressor.
What I discovered is that while everything works, it works very slow on my local machine (5-6s per opening a new page). I'm not very experienced in web development so I'm not sure what could be causing this.
If it's relevant, I don't use a frontend yet and I'm sticking to Django's templates.
I tried to download a sample django libsass project and put bootstrap there and the outcome was the same.
I expected the time for loading the pages to increase slightly due to the fact that now it has to compile scss files but not so much.
Googling turned up no results:(
Is this an expected behavior when debugging from a local machine or am I missing something? Huge thanks!

How do I prevent my Django Database from being overwritten

Currently I have a Django application running on my personal website from PythonAnywhere.com. When I make updates to the site I login to PythonAnywhere and git pull to update my application. When I do this the data that was entered through the website since the last update gets lost from the database when I update. What can I do to overcome this?
I am currently using the SqlLite version that comes preinstalled with the Django App. This likely could be part of the issue but need some help understanding how to overcome it.
I presume that your Django project is connecting to the SQLite database that gets generated when you create a new project and you are pushing that database in your deployment. That database won't be suitable for production and won't retain your changes, you instead need to setup a database that your application can connect to.
Here is some information on PythonAnywhere about databases:
https://help.pythonanywhere.com/pages/KindsOfDatabases/
And the Django documentation:
https://docs.djangoproject.com/en/4.0/ref/databases/

How to force reload only some sources in Chrome/Firefox

I’m developing a web application written in Django, I’m running the server in my machine and use Chrome/Firefox to view and test the website. I want to be able to work on it while I’m on a plane/tube and I don’t have internet.
Now, the HTML loads some resources from the local server but some others from external CDNs. I want to work on some js and css files that are hosted on my machine and view the changes in the browser, so I have to force reload the website since chrome by default just shows the cached versions of these, but if I force reload, then ALL sources are reloaded and the CDN sources obviously fail to be fetched (and my site looks horrible).
So I want to know how I can reload (in Chrome or Firefox) only some of the sources of my site and still use the cached versions of the CDN ones (assume these are cached because I load them before going into the plane).
Any help or advise on how other people would solve this would be much appreciated.

Webpack prod config vs dev config issues

I am trying to reuse one webapp that's been open sourced a while ago that was written using some Django and ReactJS... Now I am a devops engineer so my skillset when it comes to JS and even Django are fairly limited so I am stuck .. My main problem is that this webapp can run just fine locally.. so I can start it and connect using http://localhost:8000 , but whenever I try and set it up on a server and make it "public" for the internal network it fails with accessing all the JS assets.
I know the problem comes with my webpack configs but I can't sort it out.. Been trying all day but I can't even find the proper documentation since it's using Webpack 2.5.
https://github.com/tsprasath/estate/tree/master/webpack
I am attaching the link to the webpack configs from the repo.. If anyone can at least point me to the right thing to look at, that would be helpful.
Thanks in advance!
I dont think its an issue with your webpack. You are trying to run your react app (which is at client side) from django server. I believe you will need to use some kind of middleware to let django know that it needs to use static files generated for react using webpack. I dont know exactly how its done, but same procedure is followed if react app needs to be served from node/express server.
Or see if this helps: https://github.com/nicholaskajoh/React-Django

Django runserver & Firefox - caching conflict with multiple local sites running separately on same port?

I'm working on several Django projects on my local machine, following a single page application architecture. To initiate the server, I have a couple copies of a script in my /bin folder containing
#!/bin/bash
python /path/to/app/manage.py runserver 8080
and have each script with the app name. This makes the application accessible via localhost:8080. In addition, I usually have the majority of my site CSS inside main.css
My issue is that I seem to be coming across a caching issue with Firefox, regardless of which application server is running. Sometimes a page will load with almost no CSS styling, but the jQuery UI elements will be initialized and I can interact somewhat with the application, although the functionality and styling is seriously broken. Refreshing the page shows no improvement, and no errors are shown in the console.
Clearing the cache and changing the port in the scrip seem to solve the issue, but it requires me to have bookmarks for each project, whereas it is pretty convenient to have a single localhost:8080 URL for all projects.
Has anyone come across this issue, and is there a solution other than clearing cache and changing ports?
This thread discusses methods to prevent client side caching of content served by the development server in Django:
Fighting client-side caching in Django
I prefer to simply disable caching in my browser though, seeing that I spend so much time on developing that I don't want to bother with the hassle of trying to prevent it in my own code.
A simple web search for "how to disable caching in firefox" came up with this:
http://support.mozilla.org/en-US/questions/764993
I'm pretty sure that searching for the same thing for different browsers will also give you expected results.
EDIT:
These guys also seem to go pretty in depth about how to prevent the caching of static files when using the Django development server.
Turn off caching of static files in Django development server
Just add something like this to /etc/hosts:
127.0.0.1 site1.dev
127.0.0.1 site2.dev
Visit site1.dev:8080, now site1 has its own cache and cookies (session) in the browser.