(myvenv)me:src orokusaki$ python manage.py shell -i ipython
Python 2.7.2 (default, Jun 16 2012, 12:38:40)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> while True:
... pass # :(
...
I have IPython installed globally, and it works while this myvenv
virtualenv is activated just fine. However, if I start the Django shell (with or without -i
), it won't use IPython. I've never had this problem before.
Note: django-admin.py
vs manage.py
won't make a difference.
Try installing it into virtualenv! :-)
I love iPython but don't like installing it in all my virtualenvs, and I've found a good solution to allow for that. Instead of using python manage.py shell
, you can just use the system iPython directly.
In order for this to work properly, you need to set the DJANGO_SETTINGS_MODULE so that it corresponds to your project.
export DJANGO_SETTINGS_MODULE=yourproject.settings
If this is your only Django project, the easiest solution is to add that line to your .bashrc
.
If you have several Django projects and want to avoid having to change the variable every time you switch between projects, you can add that export line above tailored to each project to the postactivate scripts of all your Django virtualenvs. For me, the postactivate script is at ~/.virtualenvs/myvenv/bin/postactivate
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With