2

I'm running a Django project with one app through an Apache server on Ubuntu with mod_wsgi.

When I run it locally on the development server, all works fine. But when I upload the files to the main server, for the first couple of page requests, it seems like it is still trying to load the old HTML pages, which is causing problems communicating with the apparently up-to-date Views.py.

For example, I have this error on the main server version:

UnboundLocalError at /dms/home/
local variable 'in_use_bottles' referenced before assignment
Request Method: GET
Exception Type: UnboundLocalError
Exception Value:    
local variable 'in_use_bottles' referenced before assignment

in_use_bottles was used in an old version of the page, but no longer, and when I less the file on the server, I see no reference to it. Of course, when I click refresh about 2 or 3 times, it suddenly works.

Does anyone have any ideas? I'm guessing it's some Apache/Django quirk with caching, but I'm not experienced enough with Django to know for sure.

Geesh_SO
  • 2,156
  • 5
  • 31
  • 58
  • did you/are you able to restart the production server after changing the file contents? – MattDMo Jan 27 '14 at 19:23
  • 2
    Check reloading the python server... – Luigi Siri Jan 27 '14 at 19:23
  • @MattDMo I did an `sudo service apache2 restart` and `sudo service apache2 reload` but it didn't seem to make a difference. @LuigiSiri The local Python server works well, it's just the server version using Apache server which has strange behaviour. – Geesh_SO Jan 27 '14 at 19:25
  • 2
    Take a look at this [question/answer](http://stackoverflow.com/questions/17058928/how-to-reload-new-update-in-django-project-with-apache-mod-wsgi). – Luigi Siri Jan 27 '14 at 19:31
  • Thanks, Luigi, I'll check it out. So was my guess correct? It caches a current version and hence doesn't look at the current source code? – Geesh_SO Jan 27 '14 at 19:35
  • [This](http://stackoverflow.com/questions/5416993/why-must-i-restart-fastcgi-process-for-django/5417447#answer-5417447) is the answer. – Luigi Siri Jan 27 '14 at 20:00
  • Superb. You've been immensely helpful, thanks mate. – Geesh_SO Jan 28 '14 at 00:17

0 Answers0