diff --git a/wagtail/wagtailcore/models.py b/wagtail/wagtailcore/models.py index e8def632b..8311f28c3 100644 --- a/wagtail/wagtailcore/models.py +++ b/wagtail/wagtailcore/models.py @@ -661,7 +661,9 @@ class Page(six.with_metaclass(PageBase, AbstractPage, index.Indexed, Clusterable override this if you wish to display extra contextual information about the page, such as language. By default, returns ``draft_title``. """ - return self.draft_title + # Fall back on title if draft_title is blank (which may happen if the page was created + # in a fixture or migration that didn't explicitly handle draft_title) + return self.draft_title or self.title def save_revision(self, user=None, submitted_for_moderation=False, approved_go_live_at=None, changed=True): self.full_clean() diff --git a/wagtail/wagtailcore/tests/test_page_model.py b/wagtail/wagtailcore/tests/test_page_model.py index 18642e9c8..20ad75115 100644 --- a/wagtail/wagtailcore/tests/test_page_model.py +++ b/wagtail/wagtailcore/tests/test_page_model.py @@ -90,6 +90,16 @@ class TestValidation(TestCase): homepage = Page.objects.get(url_path='/home/') self.assertEqual(homepage.draft_title, homepage.get_admin_display_title()) + def test_get_admin_display_title_with_blank_draft_title(self): + # Display title should fall back on the live title if draft_title is blank; + # this can happen if the page was created through fixtures or migrations that + # didn't explicitly account for draft_title + # (since draft_title doesn't get populated automatically on save in those cases) + Page.objects.filter(url_path='/home/').update(title='live title', draft_title='') + homepage = Page.objects.get(url_path='/home/') + + self.assertEqual(homepage.get_admin_display_title(), 'live title') + def test_draft_title_is_autopopulated(self): homepage = Page.objects.get(url_path='/home/')