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
- Add custom fields to the built-in Group model by jmoppel 1 month, 1 week ago
- Month / Year SelectDateWidget based on django SelectDateWidget by pierreben 4 months, 3 weeks ago
- Python Django CRUD Example Tutorial by tuts_station 5 months, 1 week ago
- Browser-native date input field by kytta 6 months, 3 weeks ago
- Generate and render HTML Table by LLyaudet 7 months ago