Why should we restart apache after changing any file in django project

I installed Django on Windows 7 on Apache / mod_wsgi. I need to stop and then start the server every time I change any Python code. Is there any way to avoid this?

This does not happen with javascript / php changes, i.e. No restart of Apache is required to view the effect of the modified code. A push in the right direction would help a lot. Thanks!

+4
source share
3 answers

Read the official documentation at this address:

http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode

+1
source

You do not need to restart Apache. Just modify the wsgi file (on UNIX, you can use touch myfile.wsgi ) and it will restart. In other words, just make sure the last modification date of your wsgi file is updated, even if the contents of the file are not.

PS I assume that you are running in daemon mode. If you use the built-in mode, then my suggestion will not help you, and I do not know if it is possible to do this ... See also this question .

Edit: Sorry, I did not know that daemon mode was only supported on UNIX . In this case, perhaps the links in another question will help, but I canโ€™t say for sure, since I have no experience with it.

+4
source

This is because Python code is cached in .pyc files. It is interpreted once, after which the cache is used. Sorry, my mistake! Thank you for pointing.

If you need to frequently change files and immediately see the results for development, use Django, which is built into the development process.

It is invoked from the command line using the python interpreter as follows: python manage.py runningerver

Then the @localhost application will be launched on port 8000

Please go read the documents!

+2
source

Source: https://habr.com/ru/post/1398786/


All Articles