- 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()
More like this
- Autoload Django Models When Using ./manage.py shell by sheats 7 years, 10 months ago
- cron/console bootstrap django by nstrite 8 years, 3 months ago
- PyCrust Shell by robvdl 8 years, 1 month ago
- Use django-admin.py instead of manage.py by whiteinge 7 years, 5 months ago
- backupdb command by msaelices 7 years, 5 months ago