Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I wasn't able to get any of the above solutions to work, but I did come up with a workaround for reloading any other non-models module in my django project (e.g. a <code>functions.py</code> or <code>views.py</code> module).</p> <ol> <li><p>Create a file called <code>reimport_module.py</code>. I stored it in the <code>local/</code> folder of my django project on my dev machine.</p> <pre><code># Desc: Imports the module with the name passed in, or imports it for first # time if it hasn't already been imported. # # Purpose of this script is to speed up development of functions that # are written in an external editor then tested in IPython. # # Without this script you have to exit &amp; reenter IPython then redo # import statements, definitions of local variables, etc. # # Note: doesn't work for Django models files, because Django caches # them in a structure called AppCache. # # Args: module to reload (string) import sys module_to_reload = sys.argv[1] # Attempt to pop module try: sys.modules.pop(module_to_reload) print 'reimporting...' except KeyError: print 'importing for first time...' # (re)import module import_str = 'from {0} import *'.format(module_to_reload) exec(import_str) </code></pre></li> <li><p>Launch shell plus (which uses an embedded IPython shell):</p> <p><code>python manage.py shell_plus</code></p></li> <li><p>Use the following to import the module you are developing:</p> <p><code>%run local/reimport_module.py 'your.module'</code></p></li> <li><p>Use IPython to test functions in your module.</p></li> <li>Make changes to the module in an external editor.</li> <li><p>Use the following to reimport the module without having to exit &amp; reenter IPython:</p> <p><code>%run local/reimport_module.py 'your.module'</code></p> <p>Note: this command was already used in step 3, so you can type <code>%run</code> then the up arrow to autocomplete it.</p></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload