Created
September 3, 2015 09:14
-
-
Save muhammad-ammar/fc51cd60e7f664680084 to your computer and use it in GitHub Desktop.
load get_model when needed
This file contains hidden or 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
get_model_func = None | |
def get_model(app, model): | |
if get_model_func is None: | |
if django is None: | |
raise import_failure | |
elif django.VERSION[:2] < (1, 7): | |
from django.db.models import loading | |
get_model_func = loading.get_model() | |
else: | |
from django import apps as django_apps | |
get_model_func = django_apps.apps.get_model | |
get_model_func(app, model) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment