[Django] Applying changes done to views.py immediately on Hostgator

Assumptions

You installed Django using Fcgi on Hostgator using their tutorial
https://support.hostgator.com/articles/django-with-fastcgi

To get the changes you just did to your views.py to be applied immediately to the deployed django application on hostgator .. Here are the steps:

  1. Use SSH to execute the following commands. (How to get your SSH to work)
  2. Get the processes of the current user
    ps -u CPANEL_USERNAME
  3. If your FCGI file name is index.fcgi, you should find it available in the list that the previous command showed. If not, then no process is currently running. Just visit your website now and the changes will be applied.
  4. If you find your index.fcgi file in the list, copy its ID (the 4-5 digits number that appears on the left).
  5. Finally, kill the process
    kill ID_YOU_GOT_IN_STEP_4
  6. Visit your website now, changes should be applied by now.

Technically speaking, when someone visits your django application on hostgator, FCGI process runs. This is done because of the htaccess file you create. The python files are compiled and ran in a, and i am quoting the FCGI website, a persistent isolated process. If people keep on visiting your website, the process will keep on running. If you make changes, they’re not compiled again because you have to wait till the current FCGI process ends. All we do here is to kill the running process and that will lead to compiling our code again, hence applying the changes.

If the application is private and no one, with you excluded, is visiting it yet .. Just wait for about 10 minutes for changes to be applied without refreshing or visiting the application. This way, the process will end and a new visit will compile the new code.

I don’t know yet the drawbacks of this but it’s perfect for the small application that I am working on now. Good luck!