Skip to content

Commit

Permalink
Implemented get_related_model in utils.compat
Browse files Browse the repository at this point in the history
  • Loading branch information
kaedroho committed Apr 9, 2015
1 parent ab6060c commit fc374bc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions wagtail/utils/compat.py
@@ -0,0 +1,5 @@
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)
2 changes: 1 addition & 1 deletion wagtail/wagtailadmin/edit_handlers.py
Expand Up @@ -6,7 +6,6 @@
from six import text_type

from modelcluster.forms import ClusterForm, ClusterFormMetaclass
from modelcluster.models import get_related_model

from django.db import models
from django.template.loader import render_to_string
Expand All @@ -23,6 +22,7 @@
from wagtail.wagtailcore.models import Page
from wagtail.wagtailcore.utils import camelcase_to_underscore, resolve_model_string
from wagtail.utils.deprecation import RemovedInWagtail12Warning
from wagtail.utils.compat import get_related_model


# Form field properties to override whenever we encounter a model field
Expand Down
2 changes: 1 addition & 1 deletion wagtail/wagtailadmin/utils.py
Expand Up @@ -5,10 +5,10 @@
from django.db.models import Q

from modelcluster.fields import ParentalKey
from modelcluster.models import get_related_model

from wagtail.wagtailcore.models import Page, PageRevision, GroupPagePermission
from wagtail.wagtailusers.models import UserProfile
from wagtail.utils.compat import get_related_model


def get_object_usage(obj):
Expand Down

0 comments on commit fc374bc

Please sign in to comment.