I know such questions exist gallore in SO. But none satisfies my problem. My code however works in localhost in my PC but not in online server. The site is
The issue is that the server is using .pyc
files as pointed out in the comments.
Depending on how you are hosting the site, you will need to restart your Django Server process to trigger updates and recompilation of .pyc
files.
For Gunicorn, this post discusses how to autoload on changes. gunicorn autoreload on source change
If you aren't using Gunicorn and post more about your server setup, I'll edit it this to match your use case.