Last active
August 29, 2015 14:07
-
-
Save PythonicNinja/8f4fbcdba9ec4cb8de7c to your computer and use it in GitHub Desktop.
import django models in django console all django versions
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
from django import VERSION | |
if VERSION[0]+VERSION[1]*0.1 >= 1.7: | |
import django | |
from django.apps import apps | |
django.setup() | |
models = apps.get_models() | |
else: | |
from django.db.models.loading import get_models | |
models = get_models() | |
for m in models: | |
exec "from %s import %s" % (m.__module__, m.__name__) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Auto imports all models to use in django console