# Wagtail CMS: Changing the Admin Display Title

Source: https://djangotv.com/videos/wagtail-cms/2019/wagtail-cms-changing-the-admin-display-title/
Date: 2019-08-12
Speakers: Kalob Taulien

## Summary

Wagtail normally uses a page’s title both in the admin and in templates, but `get_admin_display_title()` lets you change only the label shown in the admin. By overriding this method on a page model—for example, returning `"Homepage is the best"`—the admin display changes while `self.title` and the page’s public title remain unchanged. The method can be applied to one model or generalized across page types, which is useful when clients use different names for content but administrators need a consistent label such as “Blog.”

## Transcript

### [00:00] Admin Display Titles

[00:00] Alright, hello, welcome to another lesson on learning Wagtail. In this video, we're gonna do something super quick. So you know when you're traversing through your pages and you have your homepage and your about and blog and all these different pages that you have throughout your website and That title, I just gotta refresh that there. And that title that you see in here is the exact same as the title that you see in here. And sometimes. Not very often, but sometimes you want to change what it says just in the admin. Not on the homepage. You don't necessarily want to change what it says when you use self dot title in your templates. You don't want to change this value at all. You just want to change what it looks like in here. And Wagtail

### [00:45] Wagtail Source Code

[00:45] there's a really cool way we can do that. So with my project open, I am just going to open Home models. py and I have a home page here and in here I'm just going to quickly explore some of the source code. So I just jumped to definition here and I'm looking at the Wagtail source code for Wagtail 2. 5. 1 And I'm just gonna keep on scrolling, keep on scrolling, and we're gonna see all sorts of stuff in here. And this is a great way to learn Wagtail, is just open up the source code and read through it a little bit. But there's one in here that caught my attention a couple days ago and I thought I would share it. And it's this one here, get admin display title And basically it just returns the draft title, or if there is no draft title, it returns the regular title.

### [01:35] Overriding the Display Title

[01:35] Well you can totally overwrite this. So I'm just gonna copy that and in my homepage And this is just model specific, so it's only going to work on this one page, but you can you can apply this to every page if you wanted to. So I'm gonna overwrite this with let's move that up. Def getAdmin display title. It takes self because it's in a Python object or a Python class rather, and I'm simply going to say return Homepage is the best. I'm gonna save that. My server has restarted with no problems. And let's refresh this here. Yes, leave the page. And we can see that it still says home page here. And I know that in my templates I can still write

### [02:22] Practical Naming Use Case

[02:22] self. title and it will still equate to the word home. But when I open this up, this now says homepage is the best. And so now a place where you might maybe use this is when a client has Maybe a blog. And that blog is generally we just call it a blog. So you're going through your page structure here. Pages, you look at your pages. So you've got your homepage, that's just the display title here. And you have a blog, but maybe the client doesn't call it a blog. Maybe they change the title to be something completely different. Maybe they say our latest news But say a year from now they also have a thousand pages in their Wagtail website and it gets a little bit hard to find that and they have to search for it every time and they would rather just look for the word blog.

### [03:11] Source Code and Resources

[03:11] Well They can just traverse through here and you could rename that to blog if you wanted to. Or in our case, you could rename homepage to homepage is the best. So that's a quick little Wagtail win if you ever want to customize that. And so just as a quick little reminder, I just jumped a definition. You can also check out the source code at github. com slash wagtail slash wagtail I'm just in Wagtailcore Models. py, and I'm in the page class. And you can just take a look through here if you like and find all sorts of cool things that you can sort of manipulate and edit and change and use to tweak your website. So I just found this one was actually super useful for a particular client I was working with. And I thought hey I'm gonna share this with the rest of the community.

[03:57] So, there you have it. Don't forget, if you like these videos, there's plenty more where that comes from, at wagtail. io slash course. You can always share, subscribe, or like this video. And as always, the source code for this entire website, which is verbosely named my website, is available at github. com slash codingforeverybody.
