Is it possible to reload a view without restarting Django?

After changing the view function without starting the server, press F5 again to refresh the page, Django will not reload the new view, but use the previous one. but if you change the template, Django always uses the new one.

So, is there a way to get Django to reload the view every time the user refreshes the page, I think it is very convenient for development to change the view function often.

+5
source share
5 answers

If you start django using a dev server (./manage.py runningerver), it will always reboot when detecting code changes. This is even more efficient than reloading with each request. If you make changes, it will reboot when needed.

If you are using a production server (nginx, apache, etc.) and want to reload the code, you need to add something to your wsgi module to detect code changes.

Reload code with apache: http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode

Reloading code with uwsgi: http://projects.unbit.it/uwsgi/wiki/TipsAndTricks

+9
source

PyDev. /cmd. cd , manage.py,

python manage.py runserver

. , eclipse, , .

+2

Django WSGI , wsgi.py , , . ( - ).

+2

, pyDev. , , , -noreload . , .

0

Try using gunicorn or nginx as a running server ... They do not restart when changing the code, try entering

gunicorn --bind 0.0.0.0:8080 app.wsgi:application

0
source

All Articles