I have done several projects with Django and the problem is that sometime the css file didn't work properly on my django template. When I made change on the css file and I reload the browser page nothing happend but when I restart my computer or turn off and turn on again the things that I changed on the css file now happen and if I make some changes again the css file and reload the browser, nothing happen again unless I restart my computer or turn off and turn on again.
This is my setting.py file
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DEBUG = True
ALLOWED_HOSTS = []
INSTALLED_APPS = [
'threeD.apps.ThreedConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'beyDimensions.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
...
STATIC_URL = '/static/'
This problem happened to me quit often, I have no idea what's wrong with django. How can I fix it?
As per you your question I can see that the changes you made in your css are not reflecting in a browser while refresh. Right! It usually happens when you don't clean up your cache memory of your browser for long time. It has nothing to do with your Django code.
So when ever you make changes in css, reload the page using Ctrl+F5
it will clear cache for that session of your browser. or you can use Incognito Mode of your browser to refresh the local host link instead of rebooting the system