What is the correct configuration for %autoreload in a Django ipython shell?
Ipython has a plugin called autoreload that will presumably reload all your modules after every command, so you can change the source and not have to quit the shell and reenter all your commands. See http://dsnra.jpl.nasa.gov/software/Python/tips-ipython.html for example.
However, this seems flaky at best when using it with Django, e.g. python manage.py shell gives me an IPython shell with Django context, but the autoreloading does NOT seem to work reliably at all.
Here's what I have added to my ipy_user_conf.py file:
def main(): ... # rest of the fn here import ipy_autoreload ip.magic('%autoreload 2')
The autoreloading works in limited cases, maybe 10-20% of the time. Has an开发者_如何学编程yone successfully configured this to work with Django?
This answer might also be applicable to your situation. Django keeps its own cache of all models, so if you want to reload everything, you have to clean this cache manually.
精彩评论