- January 16, 2008
- django model manage.py shell ipython
- 9 (after 9 ratings)
This is a little improvement to the idea from sheats a few days ago.
I like it over the previous solutions because it doesn't involve doing anything other than running
./manage.py shell inside your project directory. You don't have to create any files anywhere or remember to call anything, and
ipython still works fine outside of a Django project.
Throw this code in
ipythonrc has apparently been deprecated).
1 2 3 4 5 6 7 8 9 10 11 12 13
def load_django_models(): try: from django.db.models.loading import get_models for m in get_models(): ip.ex("from %s import %s" % (m.__module__, m.__name__)) except ImportError: print "INFO: could not find a django env" ... def main(): ... load_django_models()