Created
September 6, 2012 17:19
-
-
Save mivanov/3658714 to your computer and use it in GitHub Desktop.
IPython notebook that sets up a Django shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "Django shell" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "# Like python manage.py shell, but WAY BETTER. Run this cell once.\n\nSETTINGS_DIR = '' # Set this if you didn't run IPython where settings.py lives.\nif SETTINGS_DIR:\n import sys\n sys.path.append(SETTINGS_DIR)\nimport settings\nimport django.core.management\nprint 'Django project loaded:', django.core.management.setup_environ(settings)", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "# Optional. Run once to all your models.\nfrom django.db.models.loading import get_models\nfor m in get_models():\n try:\n get_ipython().ex(\"from %s import %s\" % (m.__module__, m.__name__))\n except ImportError, e:\n print 'Warning:', e", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "# Start hacking here!\n", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [] | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment