diff --git a/wagtail/contrib/modeladmin/tests/test_page_modeladmin.py b/wagtail/contrib/modeladmin/tests/test_page_modeladmin.py
index fb13004880..127dc3a100 100644
--- a/wagtail/contrib/modeladmin/tests/test_page_modeladmin.py
+++ b/wagtail/contrib/modeladmin/tests/test_page_modeladmin.py
@@ -4,7 +4,7 @@ from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group, Permission
from django.test import TestCase
-from wagtail.tests.testapp.models import BusinessIndex
+from wagtail.tests.testapp.models import BusinessIndex, EventCategory, EventPage
from wagtail.tests.utils import WagtailTestUtils
from wagtail.wagtailcore.models import GroupPagePermission, Page
@@ -125,6 +125,29 @@ class TestInspectView(TestCase, WagtailTestUtils):
response = self.get(4)
self.assertContains(response, 'Christmas', 2)
+ def test_manytomany_output(self):
+ """
+ Because ManyToMany fields are output InspectView by default, the
+ `categories` for the event should output as a comma separated list
+ once populated.
+ """
+ eventpage = EventPage.objects.get(pk=4)
+ free_category = EventCategory.objects.create(name='Free')
+ child_friendly_category = EventCategory.objects.create(name='Child-friendly')
+ eventpage.categories = (free_category, child_friendly_category)
+ eventpage.save()
+ response = self.get(4)
+ self.assertContains(response, '
Free, Child-friendly', html=True)
+
+ def test_false_values_displayed(self):
+ """
+ Boolean fields with False values should display False, rather than the
+ value of `get_empty_value_display()`. For this page, those should be
+ `locked`, `expired` and `has_unpublished_changes`
+ """
+ response = self.get(4)
+ self.assertContains(response, 'False', count=3, html=True)
+
def test_location_present(self):
"""
The location should appear once, in the field listing
diff --git a/wagtail/contrib/modeladmin/views.py b/wagtail/contrib/modeladmin/views.py
index 7ae5999e03..751102c5b1 100644
--- a/wagtail/contrib/modeladmin/views.py
+++ b/wagtail/contrib/modeladmin/views.py
@@ -861,6 +861,14 @@ class InspectView(InstanceSpecificView):
# we can render something useful. raises AttributeError appropriately.
val = getattr(self.instance, field_name)
+ if isinstance(val, models.Manager):
+ val = val.all()
+
+ if isinstance(val, models.QuerySet):
+ if val.exists():
+ return ', '.join(['%s' % obj for obj in val])
+ return self.model_admin.get_empty_value_display(field_name)
+
# wagtail.wagtailimages might not be installed
try:
from wagtail.wagtailimages.models import AbstractImage
@@ -880,7 +888,9 @@ class InspectView(InstanceSpecificView):
pass
# Resort to returning the real value or 'empty value'
- return val or self.model_admin.get_empty_value_display(field_name)
+ if val or val is False:
+ return val
+ return self.model_admin.get_empty_value_display(field_name)
def get_image_field_display(self, field_name, field):
""" Render an image """