1

I have a sample Django app which is being hosted on an Apache2 server using mod_wsgi. Currently I am testing it only on the loopback address (127.0.0.1). So this is what I do:

  1. Open a tab and go to the loop back address. And then I work on the Django app.
  2. Now when I start another tab and go to the loopback address, the Django app does not start from scratch. It shows me the exact same thing happening in the other tab.

How do I avoid this situation? Will it be resolved automatically if I run the app on the web? I am very new to this and I have not been able find a solution on google. I can provide any file needed to resolve the issue.

Yathi
  • 1,011
  • 1
  • 12
  • 21
  • 2
    What are you expecting to see? What does "start from scratch" mean in this case? Are you saying that a new tab goes to exactly the same URL as in the previous tab? – Daniel Roseman Jan 26 '15 at 18:42
  • Django is not PHP that usually reinterprets the whole page each request. The same app instance will keep running and answering requests unless you configure apache to kill it after N pageviews. – Paulo Scardine Jan 26 '15 at 18:44
  • @PauloScardine I did not know that! Is there any way I can force Django to behave otherwise and load a new app instance for each page request. I am trying to conduct a user study and at least 20 users will be using the app simultaneously. – Yathi Jan 26 '15 at 20:34
  • Yes, you can set `maximum-requests=1` but it will trash performance. – Paulo Scardine Jan 26 '15 at 21:19
  • Will that kill the already running process? I do not want that to happen. – Yathi Jan 26 '15 at 21:24
  • No, it will start a new process for every request a bit like PHP without FPM - it may be OK for development but I would avoid it at all costs in production. – Paulo Scardine Jan 26 '15 at 21:36

2 Answers2

1

You may be used to PHP, where you don't need to restart the server when you make changes to the PHP source code. For development purposes, you can set maximum-requests=1. This will start a new WSGI process for each request.

You may also be interested in this question: How to automatically reload Django when files change?

Community
  • 1
  • 1
Paulo Scardine
  • 73,447
  • 11
  • 124
  • 153
0

The built-in development server (that you get by doing python manage.py runserver) will refresh whenever you make a change. Apache will not (by default).

You either need to restart apache, or you need to set maximum-requests=1 in your WSGI config.

The way to go is to run the built-in dev server for development, and then deploy to an apache server for production.

Alex
  • 4,316
  • 2
  • 24
  • 28