Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear code cache in python/django?

Tags:

python

django

Sorry, I'm newbie on python. I change code in .py file but no changes happens. Guess, script code is cahced in memory.

What should I do to make my changes working?

PS: tried to delete complied .pyc file, no luck 8-( guess, IO need to try to restart uwsgi/nginx?

like image 978
mishaikon Avatar asked Jun 30 '26 23:06

mishaikon


2 Answers

Older versions of django

find . -name "*.pyc" -exec rm -rf {} \;

New version of django has this:

python manage.py clean_pyc

If you simply want to restart the webserver it depends on the configuration you are using:

  1. via gunicorn: use --reload option

  2. via django inbuilt runserver: since version 1.7 it automatically does that.

like image 64
anand Avatar answered Jul 02 '26 13:07

anand


Just touch the WSGI file: touch wsgi.py and your project should refresh.

Please have a look at this similar request: How to reload new update in Django project with Apache, mod_wsgi?

like image 38
m_____z Avatar answered Jul 02 '26 13:07

m_____z