'Problem with Django does not detect change in python code every time need to restart the server (problem in runserver)
I have a problem my django server does not show the updated python code when refreshing the page everytime i need to restart the server i searched the internet and all what i found is when i run the server
./manage.py runserver
it automatically detect any change in the code but i use it and it does not detect the change any help
def index(request):
name = "David"
return render(request, "index.html", {"name": name})
HTML file
<!DOCTYPE html>
<html>
<head>
<h1> How are you doing today {{name}} </h1>
</head>
<body>
</body>
</html>
settings.py
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp', # this is myapp that have the index function
]
Django Version
Django==3.2.8
pytz==2021.3
every time i refresh it shows David D the previous value of name not the new one i have to restart the server to show the new value
Also when changing the HTML code it detect the change and just refreshing the page is sufficient(no need to restart the server) for python it is another story it does not detect any change (need to restart the server to detect the change)
i also tried making different projects
update:
I tried another Django version
Django==2.1.5 and it works fine I really do not know
the cause of the problem but changing the version seems to work
update 2: I have tested the 3.2.8 version of django on another PC and it is working fine so i do not know where is the problem
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
