Check Django version instead of hasattr

pull/1146/head
Karl Hobley 2015-04-01 10:52:14 +01:00
rodzic 92bb4f980b
commit 1ba88cf7d0
1 zmienionych plików z 7 dodań i 1 usunięć

Wyświetl plik

@ -1,5 +1,11 @@
import django
def get_related_model(rel):
# In Django 1.7 and under, the related model is accessed by doing: rel.model
# This was renamed in Django 1.8 to rel.related_model. rel.model now returns
# the base model.
return getattr(rel, 'related_model', rel.model)
if django.VERSION >= (1, 8):
return rel.related_model
else:
return rel.model