Skip to content
Advertisement

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

JavaScript

it automatically detect any change in the code but i use it and it does not detect the change any help

JavaScript

HTML file

JavaScript

settings.py

JavaScript

Django Version

JavaScript

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

Advertisement

Answer

I just found the reason for this problem in my settings.py file

JavaScript

I was doing

JavaScript

Now after using

JavaScript

It is working fine Django version == 3.2.8 in this version do not forget to import os and for the other versions I used os.path.join so that explains why it was working, beside if you are doing the urls.py files well it will work even without including the templates in DIR list

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement