Skip to content

Instantly share code, notes, and snippets.



Last active Aug 29, 2015
What would you like to do?
import django models in django console all django versions
from django import VERSION
if VERSION[0]+VERSION[1]*0.1 >= 1.7:
import django
from django.apps import apps
models = apps.get_models()
from django.db.models.loading import get_models
models = get_models()
for m in models:
exec "from %s import %s" % (m.__module__, m.__name__)

This comment has been minimized.

Copy link
Owner Author

@PythonicNinja PythonicNinja commented Sep 29, 2014

Auto imports all models to use in django console

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.