mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-17 19:51:11 +00:00
Implemented get_related_model in utils.compat
This commit is contained in:
parent
012209cc24
commit
4b5341fd79
3 changed files with 7 additions and 2 deletions
5
wagtail/utils/compat.py
Normal file
5
wagtail/utils/compat.py
Normal file
|
|
@ -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)
|
||||
|
|
@ -6,7 +6,6 @@ import warnings
|
|||
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
|
||||
|
|
@ -23,6 +22,7 @@ from wagtail.wagtailadmin import widgets
|
|||
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
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ from django.contrib.auth import get_user_model
|
|||
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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue