Skip to content

Commit

Permalink
Fixing RemovedInDjango19Warning related to get_model. fixes issue ope…
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared Proffitt committed Sep 2, 2015
1 parent afa5cfe commit 79f45e2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions swapper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,17 @@ def load_model(app_label, model, orm=None, required=True):
if orm is not None:
return orm[join(app_label, model)]

from django.db.models import get_model
try:
cls = get_model(app_label, model)
try:
# django >= 1.7
from django.apps import apps
cls = apps.get_model(app_label, model)
except ImportError:
# django < 1.7
from django.db.models import get_model
cls = get_model(app_label, model)
except LookupError:
# both get_model versions can raise a LookupError
cls = None

if cls is None and required:
Expand Down

0 comments on commit 79f45e2

Please # to comment.