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
- Browser-native date input field by kytta 1 month, 1 week ago
- Generate and render HTML Table by LLyaudet 1 month, 2 weeks ago
- My firs Snippets by GutemaG 1 month, 3 weeks ago
- FileField having auto upload_to path by junaidmgithub 2 months, 4 weeks ago
- LazyPrimaryKeyRelatedField by LLyaudet 3 months, 1 week ago